Save 15% on Instant Deploy Bare-Metal Servers in 26 Global Markets with Coupon Code: EdgeSave

How can I change the port ssh listens on?

You can edit sshd_config to change the port sshd listens on. The default directory for ssh configuration is /etc/ssh.
Backup the current configuration and use your favorite editor to change the Port line:

root@root [~]# cd /etc/ssh/
root@root [/etc/ssh]# cp sshd_config
root@root [/etc/ssh]# vi sshd_config

#Port 22

I will set mine to port 4000. Do not forget to remove the comment (#).

Port 4000

root@root [/etc/ssh]# diff sshd_config
< Port 4000

> #Port 22
root@root [/etc/ssh]#

Restart sshd and verify that it is listening on the new port.

root@root [/etc/ssh]# /etc/init.d/sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
root@root [/etc/ssh]# netstat -anp | grep sshd
tcp        0      0      *                   LISTEN      1605/sshd
Share on Twitter
Share on Facebook