Better SSH key management.
SSH is good, but too many KEYS!
Once the number of servers you have to manage reaches 5 or more, SSH keys will become a mess. Do I need to generate a new key pair for every machine? I don't want to upload keypairs to every server, and rotating them takes ages. This also imposes security threats.
Overhaul, here are some ideas.
We need a big change. Here are goals I wish to achieve.
Only ONE key and that's enough!
No key pairs on each server due to security concerns.
Able to ssh back and forth between servers, no password required.
Able to access GitHub/GitLab repositories with the same SSH key.
WinSCP can access servers without a password.
I will also cover the setup for Synology DSM, OpenWRT (dropbear).
What do we need?
For Linux, these usually come with distribution.
What's a ssh agent?
An agent? As scary as it sounds, a ssh-agent acts like a single point of key authentication center. Every time an ssh server needs a key to authenticate a client, the server will speak with the center. (I may be wrong, but never mind.)This saves me from bringing keys with me all the time, e.g. store dozens of keys on a server.
THREE steps left
1. Generate a new keypair, and protect it with a password.
id_ed25519 is the private key.
id_ed25519.ppk is the private key used by Putty/WinSCP (if you use win)
id_ed25519.pub is the public key.
Generate using ssh-keygen
This will generate id_ed25519 and id_ed25519.pub.
Linux
$ ssh-keygen -t ed25519
Windows
Open a command line and run 'ssh-keygen -t ed25519'.
Use puttygen to convert the private key for Putty/WinSCP: id_ed25519.ppk.
Generate using puttygen
You may use puttygen too. Follow instructions here, here and here.
2. Distribute the public key.
Add the content of the public key to ~/.ssh/authorized_keys on each server.
3. Run an agent on the client machine
Windows
Putty/WinSCP
Windows
Putty/WinSCP
Run pageant.exe and you may find it in tray icon area.
Add the .ppk private key to it.
https://kerneltalks.com/howto/how-to-forward-ssh-key-in-putty/
Git (Git Bash)
Open Git Bash
$ eval $(ssh-agent -s)
https://killtheradio.net/how-tos/ssh-agent-on-cygwin/
Linux
Add the following command to ~/.profile or ~/.bash_profile.
eval $(ssh-agent -s)
This will start a ssh-agent in an interactive login shell.
Comments
Post a Comment