How to change the ssh port on Linux

To Change the SSH Port for Linux Server

  1. Connect to your server via SSH
  2. Switch to the root user
  3. Run the following command:
    nano  /etc/ssh/sshd_config
  4. Locate the following line:
    # What ports, IPs and protocols we listen for
    # Port 22
  5. Remove # and change 22 to your desired port number.
  6. Restart the sshd service by running the following command:
    service sshd restart

After you’ve made the above changes, restart the SSH daemon to reflect changes and issue netstat or ss command to confirm that SSH service listens on the new TCP port.

systemctl restart ssh
netstat -tlpn| grep ssh
ss -tlpn| grep ssh
  • ssh port, change ssh, change ssh port
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

How to Set Up a Mac for Your Kids

Providing children with access to a computer and the internet is increasingly important, but so...

How to Get Help With a Command from the Linux Terminal

Whether you’re an inexperienced terminal user or a grizzled veteran, you won’t always know the...

How To Install screenFetch in Linux

If you've browsed Linux groups on social media, you've probably seen a lot of screenshots that...

Static IP vs. Dynamic IP Address

A static IP address is one that remains fixed and never changes. The PC always sees the same...

SSH Commands - Linux SSH Commands

Navigating in UNIX pwd Shows the full path of the current directory ls Lists all...

Powered by WHMCompleteSolution