can somebody give me a walkthrough on how to set up multiple ssh keys ? What I'm trying to connect to is my remote server and GitHub account. I've got ssh access established with GitHub but when I used ssh-keygen -t rsa and hit Enter terminal prompted me if I want to override the one that already exists. How can I create new ssh key just for server ?


You should specify the output file, eg:

ssh-keygen -t rsa -f ~/.ssh/my-new-key

then to connect:

ssh -i ~/.ssh/my-new-key 192.168.x.x

or setup a ssh config file:

nano ~/.ssh/config

then put something like:

Host my-server
    HostName 192.168.x.x
    User root
    Port 22
    IdentityFile /home/username/.ssh/my-new-key


ssh my-server
  • Swell ! All I had to do is create a separate folder for the new key so it wouldn't be in conflict with the other one. Very nice ! What I don't understand though is I intentionally set the ssh key to be password-free but when I type ssh my-server and hit Enter I get prompted for password. – Mark Alexa Jun 28 '17 at 13:48
  • 1
    I'm not sure, make sure that ssh-agent is running and use ssh-add to add your key to key lists so it doesn't ask you for password anymore. (At this session). – Ravexina Jun 28 '17 at 13:52
  • I just realised that it's not a new folder what I created. I just gave it a name. I didn't know you can name a ssh key. Good to know ! – Mark Alexa Jun 28 '17 at 13:53
  • Shouldn't I copy the unique ssh formula into server's ssh file of known keys ? I think it should work similar to GitHub at this regard. – Mark Alexa Jun 28 '17 at 13:55
  • You should add your new public key to your server, known hosts will be updated automatically... – Ravexina Jun 28 '17 at 13:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.