4

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?

  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Server Fault](http://serverfault.com/) or [Webmaster Stack Exchange](http://webmasters.stackexchange.com/) would be a better place to ask. – jww Aug 18 '18 at 11:57
  • Well maybe it's not exactly about programming, but this question is related to deploying asp app that I develop on a server and to be fair, there are tons of similar no-programming questions here, for example https://stackoverflow.com/questions/4503492/using-pscp-and-getting-permission-denied – Paweł Audionysos Aug 18 '18 at 12:11
  • 1
    @PawełAudionysos Look https://stackoverflow.com/a/49063477/7073340 I think it's not possible – Jayendran Aug 18 '18 at 12:36
  • Tanks, I've seen this but I actually do have an public ip. I have response from vm but I don't know how to specify ssh key to access it. – Paweł Audionysos Aug 18 '18 at 12:41
  • @PawełAudionysos Not sure this works, Could you try saving the Keys in `Azure Key Vault` https://serverfault.com/questions/848168/putting-rsa-keys-into-azure-key-vault – Jayendran Aug 18 '18 at 13:02
  • I will try that later, thanks again :) – Paweł Audionysos Aug 18 '18 at 13:05
  • I find `~/.ssh/authorized_keys`, which holds your authorized public keys, and its permissions are the most important part. That's assuming the basics are in place. I think you will be better served asking on a site like [Unix & Linux Stack Exchange](http://unix.stackexchange.com/). That's where I asked my SSH server questions when trying to setup and debug connection problems. And OpenSSH does not make it easy on you. They provide non-sensical debug messages like [here](https://superuser.com/q/962888/173513). – jww Aug 18 '18 at 14:13
  • 1
    Just drag and drop the keys onto the Cloud Shell window, then use `-i your_new_id_rsa` with ssh. – evilSnobu Aug 18 '18 at 21:08
  • @PawełAudionysos If the answer is helpful or for more help, please let me know. – Charles Xu Aug 22 '18 at 07:12

1 Answers1

3

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.
Charles Xu
  • 29,862
  • 2
  • 22
  • 39