How to change the SSH port (Linux - Ubuntu)
![]()
- Once logged in type:
sudo -i
- Enter the account password to enter sudo edit mode.
![]()
- Once in sudo edit mode enter the command:
vi /etc/ssh/sshd_config
- Type /Port22 to highlight Port 22 and then delete the "#" to uncomment it.
- Change the port to the new port number.

- Use "Ctrl+x" to save.
- Once out of sudo edit mode enter the command:
systemctl restart ssh.service
- Disconnect from the server.
![]()
- On your desktop open CMD or Putty and enter the following command:
ssh -p <new port> userid@ipaddress
![]()
