←back to thread

637 points h1x | 2 comments | | HN request time: 0s | source
Show context
kybernetyk ◴[] No.29208914[source]
So a little offtopic but I’m still curious: how do you handle multiple machines and SSH keys? I mean do you run ssh-keygen on a new machine and have for each computer a separate key pair or do you have one key pair that you copy on every new machine?

I have seen both and using one key pair looks very convenient but also makes me feel a little uneasy.

I myself have a key pair for each of my machines.

How do you handle it?

replies(5): >>29208933 #>>29209007 #>>29209086 #>>29209300 #>>29209370 #
adrian_b ◴[] No.29209086[source]
You can avoid specifying a lot of parameters at each SSH connection by defining aliases, e.g. of the form ssh-servername.

In each alias you put the appropriate "-i private_key_for_that_server", the server name and also "-l user_name" if you have a different user there and "-p port" if the server uses a non-standard port.

Thus, after the initial key setup, connecting to any server with different credentials is no more complex than when using a single key pair.

Except for an extra keygen step, the initial setup is not more complex than when using a single key pair, as you have to copy the public keys anyway, which is the more difficult part of the setup.

replies(1): >>29209663 #
theli0nheart ◴[] No.29209663[source]
You might want to look into using .ssh/config instead, as it is built into SSH. In addition to letting you specify keys/usernames for arbitrary hosts, you can also use rules for wildcards, etc.
replies(1): >>29209739 #
1. rsfern ◴[] No.29209739[source]
Shell completion over ssh is one of the really nice benefits of sshconfig. I’m not sure if this is zsh specific though
replies(1): >>29209776 #
2. theli0nheart ◴[] No.29209776[source]
It’s definitely not, I use bash and completion works great. I’d be surprised if there was a major shell that was not supported.