In this guide I explain how you connect to Azure Linux server using SSH. I will first create a Linux server (Ubuntu) and then connect to the server using SSH on a Windows 11 device.
1. Create an ubuntu server and use the default settings. Make sure SSH public key is selected as Authentication type.
2. Depending on your situation configure the inbound ports. I will be using a site-to-site connection so I don’t need any public inbound ports. But if you connect using a public IP address you need to enable the ssh (22) port.
3. Configure your network settings for your situation. I’m using my Vnet which is connected to my onsite network using a vpn. But you may need to configure a new Virtual Network, Subnet and Public IP to provide connectivity to your server.
4. On the other tabs, I use the default settings. On the review + create page, press “Create” to create the server.
5. A pop-up appears asking you to generate a new key pair. Press “Download private key and create resource” to download the private key and start server creation.
6. A private key (PEM) will be downloaded. Save this file in a secure location.
Adjust Permissions of the PEM file
To use the pem file for connection, the permissions must first be changed. If you don’t, you will get def error message “It is required that your private key files are NOT accessible by others.This private key will be ignored.” when connecting.
7. In the explorer, go to the saved file and open its properties.
8. Select the tab security (1) and press advanced (2).
9. Press the button “Disable inheritance” (1) and press “convert inherited permissions” (2) to maintain the current rights. Press “OK” (3) to close the advanced settings.
10. Now we need to remove the permissions for the “Authenticated Users” and “Users” group. Press “edit” to edit the permissions.
11. Remove the permissions for the “Authenticated Users” and “Users” group and press ok
12. Now I need to grant my user the rights to the key. Because I’m using an Azure AD joined computer I cannot press “Add…” and select the user, but I need to utilize Powershell.
icacls "C:\yourpath" /t /grant azuread\<FirstLast>:M
13. My account has now been added with modify rights. The file now has the following rights
14. Close the properties by pressing “OK” and copy the path of the file.
Connect to the Linux server using SSH
Now we will connect to the Linux server using SSH and the certificate in Windows Terminal.
15. In Azure open the properties of the server. Select “connect” (1) and press Native SSH “Select” (2)
16. Paste the path in the provide path (1) and copy the ssh command with the pem path (2).
17. Open terminal and paste the command. Enter “yes” to continue
18. Now you’re connected to the Ubuntu server using SSH
Issues
If you’re experiencing issues with connecting to the server. You can remove the ip address of the list with known hosts using ssh-keygen
ssh-keygen -R <host name/ip> ssh-keygen -R 10.1.1.8