Comment ce connecter sur une VM Linux en SSH ?

Jean-Manuel VILLEGAS 0 Reputation points
2023-08-18T10:32:47.9633333+00:00

Nous souhaitons nous connecter à une VM Linux dans AZURE mais nous ne comprenons pas la connexion en SSH.

La clef SSH est-elle unique par profil ou poste de travail ? Quel impact si régénération d'une clef ?

Comment trouver le chemin de la commande SSH ?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,033 questions
{count} votes

1 answer

Sort by: Most helpful
  1. vipullag-MSFT 26,487 Reputation points Moderator
    2023-08-18T14:21:51.3333333+00:00

    Hello Jean-Manuel VILLEGAS

    Connecting to a Linux VM in Azure using SSH involves several steps.

    Generate SSH Key Pair (if not already done):

    If you haven't already, you'll need to generate an SSH key pair on your local machine. This key pair consists of a private key (usually named id_rsa) and a public key (usually named id_rsa.pub). You can generate a key pair using the ssh-keygen command.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

    Add the Public Key to Azure:

    In the Azure portal, navigate to your Virtual Machine's settings. Under the "Settings" section, you'll find "SSH keys" or "Password reset." Add the contents of your id_rsa.pub (the public key) to the list of authorized keys. This step allows your VM to authenticate you based on your public key.

    Connect to the VM:

    Once your public key is added to the VM, you can use the ssh command to connect to it.

    Open your SSH client. If you're using a Linux or macOS machine, you can use the built-in terminal. If you're using Windows, you can use a third-party SSH client like PuTTY.

    ssh username@public_ip_address

    If you generated your SSH key pair in a custom location, you can specify the private key's path using the -i option:

    ssh -i /path/to/private/key username@public_ip_address

    Regarding your question about SSH keys, SSH keys are unique per user profile. Regenerating a new key pair will not impact existing connections, but you will need to add the new public key to the VM to continue connecting. It's a good practice to rotate your keys periodically for security reasons.

    To find the path of the SSH command, you can run the following command in your terminal:

    which ssh

    Ref: https://learn.microsoft.com/en-us/troubleshoot/azure/virtual-machines/troubleshoot-ssh-connection

    Hope this helps.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.