I followed Miguel Grinberg’s tutorial setting up an SSH key on my desktop using ssh-keygen. I thought I could simply copy the private key id_rsa and public key id_rsa.pub to ~/.ssh directory on a new computer and SSH would work as on the first computer.
It does not work. I googled and found a Q&A on askubuntu.com. There are many answers to the question but only the answer by Victor Timoftil is related to what I am looking for. The simple answer is that,
Move ~/.ssh to the new machine and run ssh-add. DONE!
The long answer is that,
In the old machine, take the folder ~/.ssh to an USB drive, or to any other storage you like.
On the new machine, put the folder under ~ aka /home/$USER.
Run ssh-add, on the new machine done.
I copy the two SSH keys files vie a flash drive that is formatted as ntfs format. The key files are having new permission 777. The ssh-add command will show an error for that. I have to use chmod 500 command to change file permissions. Also the ssh-add will ask a passphrase which is entered when you create the keys. It seems to be a safety feature to prevent someone stealing the two key files.
Update (6/28/2020): I find the above method is not a good practice of handling SSH keys. It is better to generate new private and public keys in a new computer and copy the new public key to the server according to a Q&A post. The server will have two public keys for the same user.
Update 2 (7/21/2020): In order to add a second public key to the github, an additional step “add your SSH key to the ssh-agent” is needed when generating the key. Follow instructions on those two github web pages.
Update 3 (11/10/2020): You can run ssh-agent automatically when you open bash shell by adding lines of code (on the linked page below) into .bashrc file.
Yes, if you change the machine from which you access your servers, you can just copy the ~/.ssh directory from the old machine to the new one. It is unnecessary (and cumbersome) to generate a new key pair for every server. You just need the private keys on your new machine.
On the user's side, it is stored in SSH key management software or in a file on their computer. The private key remains only on the system being used to access the remote server and is used to decrypt messages.
You can copy your public key using the OpenSSH scp secure file-transfer utility, or using a PowerShell to write the key to the file. The example below copies the public key to the server (where "username" is replaced by your username). You'll need to use the password for the user account for the server initially.
To copy FROM the micro editor running on your remote machine over ssh: WORKS (you MUST use Shift + select, AND Ctrl + Shift + C): Hold down Shift + mouse select in the remote micro, then Ctrl + Shift + C; then on the local PC to paste: Ctrl + V or Ctrl + Shift + V or middle-mouse-click.
If you wish to gain regular access to the Git Fusion host, you can specify the correct key in your ssh command. Alternatively, you can manage multiple SSH keys using the SSH 'config' file on your local machine. This file is located at '~/. ssh/config' when using Linux, Mac or 'Git Bash' on Windows.
Changing the host's public key is fine, as long as the host also gets a new certificate. You can safely reuse host names and even run multiple hosts with the same name. You'll never see a host key verification failure again.
Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.
We notice you're using an ad blocker
Without advertising income, we can't keep making this site awesome for you.