Search code examples
azuressh-keysazure-cloud-shell

Azure portal bash file structure for ssh file


I ran a bash command from my azure subscription on portal.azure to create a ssh key and it asked me to give the name of the new file but at a location that I am not able to find on my machine. It gave a default path as /home/username/.ssh/id_rsa I cant seem to find a home directory on my machine. It went ahead and created it but I am so confused as to where it placed it.

Can someone shed some light on this. Do the bash commands run on portal.azure know the file structure of my machine and if it didnt put it under my machine, where did it place it?

ssh-keygen -m PEM -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):

Solution

  • When using the bash command line in the Azure portal, it means you use the Azure Cloud Shell, not your local machine. So the SSH key you created is stored in the cloud shell with the path /home/username/.ssh/, not the local machine.

    Here is a screenshot that creates the SSH key in the Azure Cloud Shell:

    enter image description here