How to use existing SSH key on my newly installed Ubuntu

I have a fresh install of Ubuntu 16.04 on my machine. Now I want to use my existing ssh key on my machine, so that I can use GitHub with my previous activities.

How do I set this up?

2 Answers

If you have a copy of your ssh keys (e.g., on a USB stick) then simply copy the key files to the ~/.ssh/ directory.

E.g.,

cp /path/to/my/key/id_rsa ~/.ssh/id_rsa
cp /path/to/my/key/id_rsa.pub ~/.ssh/id_rsa.pub
# change permissions on file
sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa.pub
# start the ssh-agent in the background
eval $(ssh-agent -s)
# make ssh agent to actually use copied key
ssh-add ~/.ssh/id_rsa

Otherwise, you will need to create a new one and add it to your GitHub account . Be sure to remove the old key from GitHub while you're at it.

6

Step 1: Give permission to ssh folder

chmod 700 ~/.ssh

Step 2: Give permission to ssh key files

chmod 600 ~/.ssh/id_rsa

chmod 644 ~/.ssh/id_rsa.pub

Step 3: Run the below command on the client machine, that will add the SSH key to the agent.

ssh-add

Now you can confirm with ssh-add -l (again on the client) that it was indeed added.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like