Samarth Agarwal
Samarth Agarwal

Reputation: 2134

Cannot SSH to Azure VM

I have a Ubuntu VM on Azure (Resource Group, not the Classic VM) and it all worked out of the box. I recently tried to SSH into the VM using Putty and I could not.

I get the error: Network Error: Connection Timed out.

I have made sure that the port 22 is opened for SSH on the VM Inbound rules.

SSH Port 22 Allowed

I had this VM setup about 2 months ago for a side project and at that time I was able to SSH easily without any troubles. Now I can't. Am I missing something?

PS: The HTTP works fine. I have the website running on it and it shows up in the browser. Also, I tried using a browser-based SSH client and it was able to SSH into the VM.

Upvotes: 20

Views: 32629

Answers (5)

Iceberg
Iceberg

Reputation: 3352

I encountered the same issue. The following is how I solve this issue:

  1. Don't add any port While creating your VM, do it only after only the VM is created
  2. Add the port 22 in the networking tab until the VM status is Running.

Upvotes: 1

Vipul Diwan
Vipul Diwan

Reputation: 1

Create below directory : mkdir -p /run/sshd

Then restart service : systemctl restart ssh

This will definitely solve your issue.

Upvotes: -4

MD. ABU TALHA
MD. ABU TALHA

Reputation: 713

When a new VM is created on Azure, by-default the Protocol TCP on Port 22 is Disabled. Need to allow this.

Follow: https://medium.com/techinpieces/practical-azure-how-to-enable-ssh-on-azure-vm-84d8fba8103e

Upvotes: -1

Dr Manhattan
Dr Manhattan

Reputation: 14077

I am adding this because it might help someone, the chosen answer did not work for me

for some reason the firewall on the ubuntu server

Go to Serial Console type in your ssh username and you will be logged into the server

Check the firewall status to see if port 22 is allowed

sudo ufw status verbose

If the rule is not there then add it

sudo ufw allow ssh

enter image description here

Upvotes: 16

user8651461
user8651461

Reputation:

Looks to be an issue with the local firewall. Try resetting the SSH configuration in the portal.

  1. Go to Azure Portal
  2. Select VM in question
  3. Select Reset Password
  4. Select Reset Configuration Only
  5. Select Update

Screenshot of the process here!

Upvotes: 35

Related Questions