How to Enable SSH on an Azure Windows VM

azuresshvirtual-machines

I need to use a Windows machine for a program that only works on Windows. I set up a Windows 10 virtual machine on Azure. On the Azure portal, at the virtual machine, under Connection, I see the details for RDP and it works with the Microsoft Remote Desktop app from the app store.

I also want to connect with SSH. Clicking on that item next to RDP, I see:

Ensure you have read-only access to the private key.
chmod 400 <name>.pem

without any indication of where to download or upload that key.

I opened port 22 on the Azure portal following these directions, and I also installed OpenSSH Server following the PowerShell section of these directions, including starting the service:

> Set-Service -Name sshd -StartupType 'Automatic'
> Get-NetFirewallRule -Name *ssh*

Name                  : OpenSSH-Server-In-TCP
DisplayName           : OpenSSH SSH Server (sshd)
Description           : Inbound rule for OpenSSH SSH Server (sshd)
DisplayGroup          : OpenSSH Server
Group                 : OpenSSH Server
Enabled               : True

From my local machine, the SSH times out to the public IP of the virtual machine:

$ ssh user@<public-ip>
ssh: connect to host <public-ip> port 22: Operation timed out

I am able to SSH into other virtual machines, so I don't think my firewall is the problem.

How can I connect to a Windows 10 virtual machine over SSH?

Best Answer

This error was prompt because you connect to the server without private key, that is requirement. Look at this site: https://docs.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops&tabs=current-page and try upload your public key after generate pair of key.

Also you might get the established TCP connections, to make sure everything with ssh server is ok, by this command on PowerShell:

Get-NetTCPConnection -State Established

Related Topic