SSH Key Setup
Mar 28, 2024I have been setting up a home server, which requires a lot of SSH
ing into it. By default, I can use the remote user's password, but I'm getting tired of typing that in every time.
I think that I can just set it up to not require a password, or maybe to remember it for some duration, but that's boring and insecure. Instead, I'm going to use SSH keys.
The gist is simple. Generate an SSH private/public keypair, upload the public key to the remote server that I want to log in to, and that's really it.
On my mac, that looks like this:
ssh-keygen
ssh-copy-id -i ~/.ssh/id_rsa.pub me@remoteServer
I need to enter my password one last time to upload the key, and there we go. But then I have to use the SSH key's passcode to log in every time, which is also not ideal. So instead I will store that passcode in my mac's keychain.
ssh-add --apple-use-keychain ~/.ssh/id_rsa
And that's it, I can now log in to the remote server without having to type in a password/passcode every single time. I think I will still need to at some interval, or maybe on relog, but that's better than every time by a long shot.