Can't Find My Generated Ssh Key
Posted : admin On 17.04.2020With a secure shell (SSH) key pair, you can create virtual machines (VMs) in Azure that use SSH keys for authentication, eliminating the need for passwords to sign in. This article shows you how to quickly generate and use an SSH public-private key file pair for Linux VMs. You can complete these steps with the Azure Cloud Shell, a macOS or Linux host, the Windows Subsystem for Linux, and other tools that support OpenSSH.
I am able to use the private key file with WinSCP and it works fine. Below is the directory listing, ssh command, and debug output. Note the 6th debug1: statement. From what I understand, it's saying it can't find my private key, even though the file name and path are correct (see directory listing). Quick steps: Create and use an SSH public-private key pair for Linux VMs in Azure.; 4 minutes to read +4; In this article. With a secure shell (SSH) key pair, you can create virtual machines (VMs) in Azure that use SSH keys for authentication, eliminating the need for passwords to sign in. My problem is that I can't add an SSH key or Deploy key without Fingerprint has already been taken and Fingerprint cannot be generated errors. The full story is a little complex, but something like this: I did once successfully add an SSH key to my new account, then couldn't successfully add a Deploy key. Replace the user and server with your username and the server address you wish to use the key authentication on. Ssh-copy-id -i /.ssh/idrsa.pub user @ server. This also assumes you saved the key pair using the default file name and location. If not, just replace the key path /.ssh/idrsa.pub above with your own key name.
Note
VMs created using SSH keys are by default configured with passwords disabled, which greatly increases the difficulty of brute-force guessing attacks.
For more background and examples, see Detailed steps to create SSH key pairs.
For additional ways to generate and use SSH keys on a Windows computer, see How to use SSH keys with Windows on Azure.
Supported SSH key formats
I've just generated my RSA key pair, and I wanted to add that key to GitHub. I tried cd idrsa.pub and idrsa.pub, but no luck. How can I access my SSH public key?
Azure currently supports SSH protocol 2 (SSH-2) RSA public-private key pairs with a minimum length of 2048 bits. Other key formats such as ED25519 and ECDSA are not supported.
Create an SSH key pair
Use the 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.
The following command creates an SSH key pair using RSA encryption and a bit length of 4096:
If you use the Azure CLI to create your VM with the az vm create command, you can optionally generate SSH public and private key files using the --generate-ssh-keys
option. The key files are stored in the ~/.ssh directory unless specified otherwise with the --ssh-dest-key-path
option. The --generate-ssh-keys
option will not overwrite existing key files, instead returning an error. In the following command, replace VMname and RGname with your own values:
Provide an SSH public key when deploying a VM
To create a Linux VM that uses SSH keys for authentication, specify your SSH public key when creating the VM using the Azure portal, Azure CLI, Azure Resource Manager templates, or other methods:
If you're not familiar with the format of an SSH public key, you can display your public key with the following cat
command, replacing ~/.ssh/id_rsa.pub
with the path and filename of your own public key file if needed:
A typical public key value looks like this example:
If you copy and paste the contents of the public key file to use in the Azure portal or a Resource Manager template, make sure you don't copy any trailing whitespace. To copy a public key in macOS, you can pipe the public key file to pbcopy
. Similarly in Linux, you can pipe the public key file to programs such as xclip
.
The public key that you place on your Linux VM in Azure is by default stored in ~/.ssh/id_rsa.pub, unless you specified a different location when you created the key pair. To use the Azure CLI 2.0 to create your VM with an existing public key, specify the value and optionally the location of this public key using the az vm create command with the --ssh-key-values
option. In the following command, replace VMname, RGname, and keyFile with your own values:
If you want to use multiple SSH keys with your VM, you can enter them in a space-separated list, like this --ssh-key-values sshkey-desktop.pub sshkey-laptop.pub
.
SSH into your VM
With the public key deployed on your Azure VM, and the private key on your local system, SSH into your VM using the IP address or DNS name of your VM. In the following command, replace azureuser and myvm.westus.cloudapp.azure.com with the administrator user name and the fully qualified domain name (or IP address):
If you specified a passphrase when you created your key pair, enter that passphrase when prompted during the login process. The VM is added to your ~/.ssh/known_hosts file, and you won't be asked to connect again until either the public key on your Azure VM changes or the server name is removed from ~/.ssh/known_hosts.
If the VM is using the just-in-time access policy, you need to request access before you can connect to the VM. For more information about the just-in-time policy, see Manage virtual machine access using the just in time policy.
Next steps
For more information on working with SSH key pairs, see Detailed steps to create and manage SSH key pairs.
If you have difficulties with SSH connections to Azure VMs, see Troubleshoot SSH connections to an Azure Linux VM.
Can I associate multiple SSH public keys with an instance?
Yes, you can associate multiple SSH public keys with your instance when you create the instance. To do this, you must upload all the required SSH public keys to Compute Classic before you start creating the instance.
Additionally, after creating a Linux or Oracle Solaris instance, you can inject more SSH public keys into the instance by logging in to the instance and editing the ~/.ssh/authorized_keys
file of the user.
If you need to edit the ~/.ssh/authorized_keys
file of a user on your instance, then before you make any changes to the file, start a second ssh
session and ensure that it remains connected while you edit the authorized_keys
file. Avast driver updater key generator. This second ssh
session serves as a backup. If the authorized_keys
file gets corrupted or you inadvertently make changes that result in your getting locked out of the instance, then you can use the backup ssh
session to fix or revert the changes. Before closing the backup ssh
session, test the changes you made in the authorized_keys
file by logging in with the new or updated SSH key.
Note:
When an instance that’s set up to boot from a nonpersistent boot disk is deleted and re-created, any SSH public keys that you added or edited manually (that is, not during instance creation) must be added or edited again. To do this, you must log in to the instance by using the original SSH private key. So retain and safeguard your original SSH private key.
Can I associate a single SSH public key with more than one instance?
Yes, you can associate an SSH public key with multiple instances.
I’ve lost access to my SSH private key. What do I do now?
A private SSH key is the only way you can access your Linux instances. If you don’t have the private key, then you can’t access your instances. Always back up an encrypted copy of your private SSH keys, and keep the keys secure.
My SSH private key has been compromised. I’ve generated a new SSH key pair and I want to update the SSH public key on my running instances. How can I do that?
To modify an SSH public key on a running instance, log in to the instance, and edit the ~/.ssh/authorized_keys
file of the user. Remove the existing SSH public key in this file and replace it with the new key.
Note:
You don’t need to do this if you’re creating a Windows instance, because you can’t log in to a Windows instance using SSH.To log in to your Windows instance using RDP, see Accessing a Windows Instance Using RDP.
If you need to edit the ~/.ssh/authorized_keys
file of a user on your instance, then before you make any changes to the file, start a second ssh
session and ensure that it remains connected while you edit the authorized_keys
file. This second ssh
session serves as a backup. If the authorized_keys
file gets corrupted or you inadvertently make changes that result in your getting locked out of the instance, then you can use the backup ssh
session to fix or revert the changes. Before closing the backup ssh
session, test the changes you made in the authorized_keys
file by logging in with the new or updated SSH key.
Note:
When an instance that’s set up to boot from a nonpersistent boot disk is deleted and re-created, any SSH public keys that you added or edited manually (that is, not during instance creation) must be added or edited again. To do this, you must log in to the instance by using the original SSH private key. So retain and safeguard your original SSH private key.
I want to give other users access to my instance, but I don’t want to share my SSH private key. What should I do?
You can create new local users on your instance, generate SSH key pairs for these users offline, and append the new public keys in theFind My Ssh Key Windows
~/.ssh/authorized_keys
file of the new users. These users can then ssh
to the instance by using the appropriate private keys. See Adding Users on an Oracle Linux Instance. 
Note:
Get Ssh Key
When an instance that’s set up to boot from a nonpersistent boot disk is deleted and re-created, any users that were added manually (that is, users that weren’t defined in the machine image) must be added again.
Can't Find My Generated Ssh Key Password
When an instance that’s set up to boot from a nonpersistent boot disk is deleted and re-created, any SSH public keys that you added or edited manually (that is, not during instance creation) must be added or edited again. To do this, you must log in to the instance by using the original SSH private key. So retain and safeguard your original SSH private key.