how can i change the port ssh listens on

From WebHostingNeeds.com
Jump to: navigation, search

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:

[email protected] [~]# cd /etc/ssh/
[email protected] [/etc/ssh]# cp sshd_config sshd_config.save
[email protected] [/etc/ssh]# vi sshd_config

Find

#Port 22

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

Port 3333

You can compare the two files to make sure there is no other changes.

[email protected] [/etc/ssh]# diff sshd_config sshd_config.save

13c13

< Port 3333

—-

> #Port 22

[email protected] [/etc/ssh]#


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

[email protected] [/etc/ssh]# /etc/init.d/sshd restart

Stopping        sshd:                                            [  OK  ]
Starting        sshd:                                            [  OK  ]

[email protected] [/etc/ssh]# netstat -anp | grep sshd

tcp       
0      0
0.0.0.0:3333
0.0.0.0:*                  
LISTEN      1605/sshd