To change which port ssh listens on, you just need to edit the sshd_config file. The default directory for ssh configuration is /etc/ssh.
- First, backup the current configuration and use your favorite editor to change the Port line:
[email protected]t [~]# cd /etc/ssh/
[email protected] [/etc/ssh]# cp sshd_config sshd_config.save
[email protected] [/etc/ssh]# vi sshd_config
- Now, locate the following line:
- For this example, we’ll set it to port 4000, by replacing “Port 22” with “Port 4000“. *Note: Do not forget to remove the comment (#).
- Lastly, restart sshd and verify that it is now 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:4000 0.0.0.0:*
And there you have it! You can set the port number to whichever port you prefer, but keep in ming that port numbers between 0 and 1,023 are reserved for existing system services. For this reason, you’re typically better off choosing a number above Port 1023.
- DNS Configuration: Everything You Need to Know
- What is Cron Job?
- How to Resolve Error 421 Service Not Available and Other Issues with FTP Service
Don’t see what you’re looking for? Use the search bar at the top to search our entire Knowledge Base.
The Hivelocity Difference
With best-in-class customer service, affordable pricing, a wide-range of fully-customizable options, and a network like no other, Hivelocity is the hosting solution you’ve been waiting for.