Urgent.News

What's breaking now, across thousands of outlets.

Tech

Azure: SSH to a VM on Azure

SSH allows for remote encrypted connection between a two computers (typically a client and server) using cryptography to authenticate and encrypt connection between the devices. In this guide, we would explore how to connect to a virtual machine created on microsoft azure using SSH. A Brief Overview of SSH Secure SHell (SSH) is a protocol on the application layer of the OSI model. It is used for…

Secure Shell (SSH) is a cryptographic protocol that enables secure remote connections between two computers. In this article, we will demonstrate how to use SSH to access a virtual machine (VM) hosted on Microsoft Azure.

SSH operates on TCP port 22 by default. To establish an SSH connection, both the client and server must have a shared secret key. This key is established through a process called asymmetric key cryptography, which generates a pair of keys - a public key and a private key. The public key is shared, while the private key remains confidential.

To create an Azure VM accessible via SSH, follow these steps:

1. Log in to the Azure portal and click "Create a Resource" on the dashboard.

2. Select "Virtual machine" and proceed to the "Create Virtual Machine" page.

3. Configure the VM settings according to your requirements. Ensure that the "Authentication Type" is set to "SSH public key."

4. Generate a new SSH key pair if necessary, and specify the key type (e.g., Ed25519 for faster performance).

5. Assign an inbound port rule, ensuring that port 22 is open.

6. Create the VM, which will generate a `key.pem` file for authentication purposes.

7. Move `key.pem` to the `~/.ssh` directory on your local machine and set its permissions to read-only (chmod 400).

To connect to your Azure VM using SSH, execute the following command in your terminal:

```

ssh -i ~/.ssh/key.pem username@public_ip_address

```

Replace `username` with your VM's username and `public_ip_address` with the VM's public IP address obtained from the Azure portal.

Upon the first connection attempt, Azure will display a message prompting you to verify the server's fingerprint. This fingerprint ensures that you are connecting to the intended VM and not an imposter. Compare the provided fingerprint with the one obtained from the VM using the following command:

```

ssh-keygen -lf /etc/ssh/ssh_host_ecdsa_key.pub | awk {print $2}

```

If the fingerprints match, continue with the connection. After verifying the fingerprint, you will be successfully connected to your Azure VM via SSH.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Thursday 17 September →