ssh notes
Below you’ll find my SSH tips and tricks. These are mostly as a note to myself, but you might find them interesting.
Generate SSH Key
I’ve started to use ED25519 SSH keys. Here’s how I generate them:
ssh-keygen -o -a 100 -t ed25519 -f ~/.ssh/id_ed25519 -C "[email protected]"
If you need the key in PEM format, run the following:
ssh-keygen -m PEM -t ed25519 -f keyname -C [email protected]
SSH Config File
In my .ssh
directory, I also have a file ~/.ssh/config
which has a bunch of hosts declared in it. Those hosts each have their own configuration and then are assigned a short name. Below is an excerpt:
Host server01
HostName server01.kilo.house
Port 22
User livearchivist
IdentityFile ~/.ssh/id_la_ed25519
This allows me to type ssh server01
instead of ssh -i ~/.ssh/id_la_ed25519 [email protected]
. Once you start getting into more and more complicated SSH connections and configurations, you can see how this would save you a lot of time.
SSH Directory Permissions
I always end up looking up the proper ownership for .ssh
directories, so rather than searching every time, here it is.
chown $USER:$USER ~/.ssh/authorized_keys
chown $USER:$USER ~/.ssh
chmod 700 ~/.ssh
chmod 644 ~/.ssh/*.pub
chmod 600 ~/.ssh/id_ed25519
chmod 644 ~/.ssh/authorized_keys