Change sshd Port
December 26, 2005 Posted by KP
I used default port number 22 for sshd, the server got lots of login attempts every day which left thousands of lines in daily security run output.
There are several variables related to port range in sysctl, mine is different from the default value, although I didn’t modify anything.
# sysctl -a | grep portrange
net.inet.ip.portrange.lowfirst: 1023
net.inet.ip.portrange.lowlast: 600
net.inet.ip.portrange.first: 49152
net.inet.ip.portrange.last: 65535
net.inet.ip.portrange.hifirst: 49152
net.inet.ip.portrange.hilast: 65535
net.inet.ip.portrange.first and net.inet.ip.portrange.last are supposed to be 1024 and 5000 according to the FreeBSD manual. I was worried being locked outside of the box and didn’t modify the sshd port.
I can’t bear the annoying automate login attempts any more and decided to give it a try. It’s easy to change:
Add a line in the file /etc/ssh/sshd_config:
Port 1234
Reload sshd
#/etc/rc.d/sshd reload
I opened another putty client to test the login, everything worked fine. The great thing is the old ssh connection is still active after the sshd modification and reload, I always have the chance to revert the configuration back if it doesn’t work.
By the way, binding the ssh login to a static IP is recommended as well.
Related Posts:
- Change FTP Port
- AllowUsers
- Reduce Server Visibility
- sysctl.conf Sample
- How to Setup Key Based Authentication in SSH
- Install via Port
Filed Under: Security
December 27th, 2005 at 3:51 pm
I also using this feature.
Also “hangup” to 22 port portsentry.
So, all “hackers” in my deny list after 5 attempt
December 27th, 2005 at 5:07 pm
I don’t use portsentry. When I test the login on port 22, no response from my server, this should be good enough as the client has to wait and can’t try another login easily. This behavior should be caused by the sysctl configuration: http://www.freebsdblog.org/archives/2005/06/avoid_network_p.html
December 6th, 2009 at 12:49 am
Hi,
I use this way for changing ssh port,but it didn’t work
I have a question about it,why?