Paweł Audionysos
Paweł Audionysos

Reputation: 606

Specify SSH private key in Azure Cloud Shell

I've created Linux VM on Azure. Locally I'm using windows. I set public key generated with PuTTy.

I've followed How to use SSH keys with Windows on Azure

I'm able to log in to VM using PuTTy by specifying "private key file for authentication", this works. However I don't know how I suppose to log in to the machine with Azure Cloud shell. I see there is -i option in ssh but the key file is on my local machine.

If i simply type ssh username@ip (as tutorial is saying) I got "Permission denied (public key)." response.

How should I do it? Can I upload the key file to azure?

Upvotes: 4

Views: 3350

Answers (1)

Charles Xu
Charles Xu

Reputation: 31424

Connect to Azure VM(Linux) from Azure Cloud Shell using ssh public key, you can follow the steps below.

  1. Open Azure Cloud Shell, then create ssh public key with the command ssh-keygen -t rsa, you can Entry all time.
  2. Go into the directory ~/.ssh/, there are the files like this: enter image description here
  3. Copy the file or the file content to the Azure VM which you want to ssh, and the directory is ~/.ssh/. If this directory has the file authorized_keys, you can change the content with id_rsa.pub.
  4. Now, you can ssh into the Azure VM with the command ssh -p port username@publicIp.

Upvotes: 3

Related Questions