ssh-keygen
command to generate SSH public and private key files. By default, these files are created in the ~/.ssh directory. You can specify a different location, and an optional password (passphrase) to access the private key file. If an SSH key pair with the same name exists in the given location, those files are overwritten.--generate-ssh-keys
option. The key files are stored in the ~/.ssh directory unless specified otherwise with the --ssh-dest-key-path
option. If an ssh key pair already exists and the --generate-ssh-keys
option is used, a new key pair will not be generated but instead the existing key pair will be used. In the following command, replace VMname and RGname with your own values:cat
command, replacing ~/.ssh/id_rsa.pub
with the path and filename of your own public key file if needed:pbcopy
. Similarly in Linux, you can pipe the public key file to programs such as xclip
.--ssh-key-values
option. In the following command, replace myVM, myResourceGroup, UbuntuLTS, azureuser, and mysshkey.pub with your own values:--ssh-key-values sshkey-desktop.pub sshkey-laptop.pub
.RSA
is the most popular asymmetric encryption algorithm. In this tutorial we will look how to create RSA keys with ssh-keygen
ssh-keygen
will create RSA keys by default. So we do not have to specify the algorithm but in order to be sure and provide information we can explicitly specify the RSA key creation. We will use -t
option in order to specify the RSA algorithm.~/.ssh/id_rsa
. We can change this default directory during the generation or by providing the path as parameter. We will use -f
option in order to change path and file name. We will create key named test
in to the current working directory.test
is the private keytest.pub
is the public key