1

I would like to generate multiple SSH keys for my different servers.

For example:

  • 1 RSA 2048 public/private key for 1.1.1.1
  • 1 ECC public/private key for 2.2.2.3
  • 1 ECC public/private key for 3.3.3.3

I understand the ssh keys are stored in the .ssh folder, but how can I copy the right public keys to the correct servers, and how can I generate multiple SSH keys without writing each-other over? I have read something about the -c command, but do not fully understand if it is able to do what I am requesting.

3
  • Short answer: Yes ... longer answer: ssh tries all keys listed in ssh-add -l ... as well as the default identities listed in ~/.ssh/ ... On Copying keys : Try ssh-copy-id Commented Dec 3, 2017 at 1:23
  • when i create a ssh key will it give the ssh key a unique id, or can i name it myself? Commented Dec 3, 2017 at 1:30
  • Crossdupe stackoverflow.com/questions/2419566/… (but you need to look at more than the first answer). -c is not a command; as an option on ssh or ssh-keygen it does (different) things completely unrelated to what you want; as an option on ssh-add it could work but would be very clumsy. Commented Dec 3, 2017 at 7:09

1 Answer 1

3

Yes, you can have multiple SSH keys. I would suggest reading the man page for ssh-keygen: http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man1/ssh-keygen.1?query=ssh-keygen%26sec=1

Use the -f option to specify your own filename.

ssh-keygen -t rsa -f myfirstrsakey 
1
  • And to use this keyfile, ssh -i file or IdentityFile file in a Host section in .ssh/ssh_config per the crossdupe I linked above. Commented Dec 3, 2017 at 7:09

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.