Despite having had some excitement recently, SSH continues to be both the utility and a protocol that I use heavily every day. I will also have to shout out to mosh which is a must have overlay, if you aren’t using it – stop reading this now and go get mosh.
Not often, but every once in a while I find myself needing to generate a new key pair for use with SSH. GitHub has one of the best articles on doing this, but it’s not quite what I want. I find myself having to re-think the small differences I want to make each time, clearly time to write up what I do so I can just visit this post when I need to generate a key.
1 |
$ ssh-keygen -t ed25519 -C "comment here" -f basename |
Yup, that’s it. In the directory you run this there will be two files generated. The private key is basename
, and the public key is basename.pub
. I’m also a fan of the .ssh/config file which you may want to adopt, this makes it easy to have different keys for different systems.
Breaking down the creation command. We are generating a key using the Ed25519 algorithm, most modern systems will support this. Next up we see that we are adding a comment, I find this useful to identify what the public key is for. Last is the filename(s) we want the output written to.
You’ll see that comments often have no whitespace in them, if you want to be risk adverse avoid using spaces and use dashes or something.