Search code examples
azure-cloud-shell

Azure Cloud Shell ssh keys persistence


I am using Azure Cloud Shell to ssh into my VMs.

I have created SSH keys, created my VMs and was able to ssh into my VMs. My Bash cloud shell session was suddenly disconnected (not the main issue) and after opening a new session to Cloud shell again I was not able to ssh into my VM anymore. I checked my .ssh dir and non of my keys were there anymore (empty).

I know the dir clouddrive is persisted but I want to confirm if .ssh is.

If not what is the way to achieve this so I do not run into this issue again.


Solution

  • No, the .ssh directory is not a persistent directory. As you know, only the directory clouddrrive can persist your files. So the possible solution is that you can store your SSH key in the clouddrive, when you use a new session, you can copy the .ssh from the clouddrive. Or add the parameter -i then the command looks like this:

    ssh -i /path/to/private_key username@IP