Issue
I created a Microsoft Azure Virtual Machine with Windows 10 as the image. I allowed it to have an SSH connection. The connection on the Microsoft Azure portal says "Network connectivity allowed". However, when I try to connect it on the Windows Subsystem for Linux using the command: ssh -i <private key path> <vm-name>@<host ip address>
it says ssh: connect to host <host ip address> port 22: Resource temporarily unavailable
. Why is this happening?
I am also wondering about the instructions on the Microsoft Azure instructions on creating a private key and then having a private key path. How am I suppose to create a private key and have a path for it?
Solution
You can check out microsoft/WSL/issue 2278, which lists a couple of issues:
- firewall
- the domain had been moved to cloud front and I needed to use the direct IP address instead of the domain name.
- I received a "Resource temporarily unavailable" error because my subnet did not have a route to an Internet Gateway
- I just had this problem because I installed Nginx in the server and it blocks SSH by default. You have to
sudo ufw allow ssh
.
Note: as explained in "Connect to an Azure Linux vm with ssh and Windows Subsystem for Linux" by matthewdavis111, you connect from WSL to Azure.
Meaning you would enter your public key in the SSH field of your Azure remote server:
On your PC, you can generate a public/private key with:
ssh-keygen -P "" -t rsa -f azure
That will create in %USERPROFILE%\.ssh
an azure
and azure.pub
files.
Copy the content of the second one (public key) to Azure settings.
Depending on your version of Windows 10, you might need to install Git for Widows, which includes ssh-keygen.exe
.
C:\path\to\Git\usr\bin\ssh-keygen.exe
In your case though, doing so in a WSL bash session is better, especially if the rest is done from that same session.
The files will be in ~/.ssh
($HOME/.ssh
)
For a Windows 10 VM, see "Creating A Win 10 Virtual Machine – Azure Portal" by Ayush Rathi.
No need for SSH then.
Connecting to the Virtual Machine and Log On:
On the Hub menu, click Virtual Machines.
Select the virtual machine from the list.
On the Virtual Machine Blade, Click on Connect. This creates and downloads a Remote Desktop Protocol file (.rdp file) to connect to your machine. Open this file to connect to your VM.
You will get a warning that the .rdp is from an unknown publisher.This is a normal warning. In the Remote Desktop window, click Connect to continue.
- In the Windows Security window, type the username and password that you entered while creating the VM. The username is entered as vmname\username, then click OK.
- You will get a warning that the identity of the remote computer cannot be verified. This is a normal warning. Click Yes to verify the identity of the virtual machine and finish logging on.
Your machine is ready and you can use it just as you would use any other machine or server.
Answered By - VonC