Oooh boy work has been insane. I can’t believe it’s been so long since I updated anything. Not that I haven’t been studying, of course. Unfortunately, though, I’ve been so tied up I didn’t meet my goal of getting certified by the end of 2015. So I’ve adjusted that to 2016. 🙂
I’ve been playing around with stuff like GitLab and Github and so tonight I setup my own GitLab server. I decided I wanted to be a good Linux citizen and use SSH keys instead of passwords when I hit a stumbling block I’d forgotten. My Mac doesn’t include ssh-copy-id. Thanks Steve.
So there are two ways you can manage this. The first is to manually copy the public key from your local computer to the remote computer. You can either edit the authorized_keys file manually or use this command to do it all in one fell swoop.
cat ~/.ssh/id_rsa.pub | ssh user@remote 'cat >> /path/to/.ssh/authorized_keys'
This will cat the public key and pipe the results via ssh to append it to the authorized_keys file. Here’s a little tip that might help if you run into problems. My CentOS 7 user didn’t have a .ssh directory so I added it. If this happens to you, make sure you set the file permissions correctly.
chmod 700 .ssh chmod 600 .ssh/authorized_keys
So that covers the first way to share your key. The second way is to use homebrew. Once you have homebrew on your Mac you can install what should have been there from the beginning.
./brew install ssh-copy-id
From there it’s a simple matter to copy your key to the remote.
If you’re like me and you have this obsession with creating keys for different endpoints you’ll need to specify the key you wish to share.
./ssh-copy-id -i /path/to/.ssh/desired_key.pub user@remote
There you go. Once you’ve done this you should be able to ssh to your remote without being prompted for your pesky password.