I have a virtual machine on Azure—for testing, not a production server—based on Ubuntu 14.04 LTS. The default SSH port 22 is opened by default.

I want to change it to 12131. I edited my SSH configuration file and changed port to 12131, then reloaded ssh service by:

service ssh reload

Then I logged into my Windows Azure portal and updated endpoint SSH as:

  • Public Port 12131

  • Private Port 12131

Now I’m getting timeout with SSH. What is the proper way to change the default SSH port on Ubuntu 14.04 in Azure?

  • This is not really an Azure question as much as an Ubuntu question. What SSH config did you edit on the server? This one: /etc/ssh/sshd_config? And what happens if you do nmap [ip address of your server] -p 12131. If that port is closed, that is the issue. Do you perhaps have a firewall like iptables installed? Also, why avoid port 22? Changing it won’t make your system more secure. – Giacomo1968 Nov 28 '14 at 7:58

I assuming you want to do it for security reasons.

You can just change the public port in Azure to something else and leave the ssh config in Ubuntu alone.

Go to the Azure dashboard, choose Virtual Machines, open your VM, go to endpoints, change the public port for SSH to 12131

Now when you try to ssh to it you will use port 12131 but it translates that to the internal port 22 set on the server, and port 22 externally goes nowhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.