Celeb Glow
general | March 17, 2026

Not able to change ssh port on Ubuntu 18.04.1 LTS [duplicate]

I am trying to change ssh port from 22 to 1111. I have taken following steps, but not able to.

  1. sudo nano /etc/ssh/ssh_config
  2. Removed # where it says Port 22
  3. Changed Port 22 to Port 1111
  4. Ctrl + W -> Y -> Ctrl + O -> Enter -> Ctrl + X
  5. sudo ufw allow 1111
  6. sudo systemctl restart ssh
  7. sudo systemctl status ssh

Output:

  1. Server listening on 0.0.0.0 port 22
  2. Server listening on :: port 22.
2

1 Answer

The file that you edited, /etc/ssh/ssh_config is the global ssh client configuration file - changing the port there will change the port which the ssh (and scp) programs try to connect to.

To change the port that the server listens on, you need to modify /etc/ssh/sshd_config :

# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
1