This is a discussion on Failed SSH login attempts and how to avoid brute ssh attacks within the Networking, Firewalls and Security forums, part of the Mastering Servers category; Hello all, Please share your tips and howto about avoiding failed login ssh attempt (brute ssh attack) and securing SSH ...
|
|||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
||||
|
Hello all,
Please share your tips and howto about avoiding failed login ssh attempt (brute ssh attack) and securing SSH based remote Login system. This is kind of a group project and I am expecting to everyone share their valuable experience. Please consider following SSH brute force attacks SSH dictionary attacks Buffer overflow attack Securing shell access via ssh Step # 1: Change the ssh port Open config file /etc/ssh/sshd_config Code:
vi /etc/ssh/sshd_config Code:
Port 678 Usually all server comes with 5 or more public IP address. No need to bind to all IP address. Just bind to one IP address. Code:
ListenAddress 65.1.5.1 Code:
Protocol 2 Code:
PermitRootLogin no Code:
DenyUsers root Code:
Banner /etc/ssh.go.txt Code:
vi /etc/ssh.go.txt Code:
************************************************************ This is a private server!!! All ssh login attempts are logged and monitored by our staff. All unauthorized login attempts will be investigated and repoeted to local authorities. If you have any login problem please contact helpdesk us at Phone: 888-555-777 or email us Email: support@mycorop.com ****************************************************************** Code:
/etc/init.d/sshd restart Code:
ssh -p PORT user@IP-address ssh -p PORT user@your.server.com ssh -p 678 rocky@65.1.5.1 Code:
scp -P 678 local.txt rocky@65.1.5.1:/home/rocky As suggested by monk you can automate password less logins with ssh client keys instead of password authentication. Type at your local Linux/UNIX workstation; create a public/private key pair: Code:
ssh-keygen -t rsa First login to remove server over ssh and create .ssh directory: Code:
ssh -p 678 user@65.1.5.1 Code:
mkdir .ssh && chmod 0700 logout Code:
scp -P 678 ~/.ssh/id_rsa.pub user@65.1.5.1:.ssh/authorized_keys2 scp -P 678 ~/.ssh/id_rsa.pub user@65.1.5.1:/home/user/.ssh/authorized_keys2 Code:
ssh -p 678 user@65.1.5.1 Code:
vi /etc/ssh/sshd_config Code:
PasswordAuthentication no Code:
/etc/init.d/sshd restart
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
| Sponsored Links | ||
|
|
|
|||
|
Rocky I am not good at securing servers but here is the command that will tell you if you are under attack. It will list failed login attempts along with host/ip address:
Code:
grep -i 'authentication failure' /var/log/messages|awk '{ print $13 }' | cut -b7- | sort | uniq -c
Code:
10 xxx.vnsl.in
12 xxx.xxx.yyy.zzz
56 xxx.xxx.yyy.zzz
__________________
Raj Linux rulz. I have never turned back in my life ; I shall not do so today.. haha |
|
|||
|
Well this can be done by installing the csf firewall found here: http://www.configserver.com/cp/csf.html
It can do all the following: This suite of scripts provides: * Straight-forward SPI iptables firewall script * Daemon process that checks for login authentication failures for: o courier imap and pop3 o ssh o non-ssl cpanel / whm / webmail (ssl cpanel/whm login tracking support available in EDGE release) o pure-pftd o password protected web pages (htpasswd) o mod_security failures * POP3/IMAP login tracking to enforce logins per hour * SSH login notification * SU login notification * Excessive connection blocking * WHM configuration interface * WHM iptables report log * Easy upgrade between versions from within WHM * Pre-configured to work on a cPanel server with all the standard cPanel ports open * Auto-configures the SSH port if it's non-standard on installation * Block traffic on unused server IP addresses - helps reduce the risk to your server * Alert when end-user scripts sending excessive emails per hour - for identifying spamming scripts * Suspicious process reporting - reports potential exploits running on the server * Excessive cPanel user processes reporting * Excessive cPanel user process usage reporting and optional termination * Suspicious file reporting - reports potential exploit files in /tmp and similar directories * Directory and file watching - reports if a watched directory or a file changes * Block traffic on the DShield Block List and the Spamhaus DROP List * Pre-configured settings for Low, Medium or High firewall security * Works with multiple ethernet devices * Server Security Check - Performs a basic security and settings check on the server * Allow Dynamic DNS IP addresses - always allow your IP address even if it changes whenever you connect to the internet * Alert sent if server load average remains high for a specified length of time To enable the ssh login failure detection do: LF_SSHD = "1"
__________________
LivE Free 0r DiE L!nux rul3z aLL |
|
|||
|
Quote:
Quote:
__________________
LivE Free 0r DiE L!nux rul3z aLL |
|
||||
|
this post rockz
make sure your file permissions on both ~/.ssh/* and server:~/.ssh/* set to 0600. Your private key file id_rsa must be present only on your local Linux/UNIX workstation. Chk out Top Ten Secure Shell FAQs http://www.oreillynet.com/pub/a/orei...tips_0101.html Quote:
Bye |
|
||||
|
Here is the line from my pf firewall script
Code:
pass inet proto tcp from any to any port 22 keep state (max-src-conn-rate 5 / 60) For iptables see tutorial written by our friends @ debian-administration.org http://www.debian-administration.org/articles/187 @sweta I do use CP for clients but personally I don't use any CP. I was not aware of csf firewall script or module. There are tons of such script exists. @bin@ry Hehe yes sometime I do write it from scratch @monk Buddy don't give us our secrets in public |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to avoid recommended memory message in RHEL | token | CentOS / RHEL / Fedora | 0 | 04-22-2008 07:08 AM |
| dovecot: pop3-login: pop3-login: error while loading shared libraries: libsepol.so.1 | raj | Mail Servers | 1 | 11-15-2007 10:43 AM |
| avoid displaying errors while executing a script | vikas027 | Shell scripting | 4 | 10-31-2007 11:57 AM |
| Linux / UNIX set increase the number of failed login retries with SSH client | sweta | Getting started tutorials | 0 | 06-12-2007 02:35 AM |
| Apache SYN Flood Attacks and how to stop / avoid them | cbzee | Web servers | 1 | 12-21-2006 03:30 AM |