Setting up a keypair and adding it to remote server:
Generate keypair (will be asked where to save if no -f, default is fine):
ssh-keygen -t ed25519 -f ~/.ssh/filename -C "<comment/email>"
Copy public key to remote server:
# with ssh-copy-id tool:
ssh-copy-id -i ~/.ssh/filename.pub USER@REMOTEHOST
# manually, permissions are required!
cat ~/.ssh/filename.pub | ssh USER@REMOTEHOST "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
Change passphrase of a file:
ssh-keygen -p -f ~/.ssh/filename
Troubleshoot:
# on the client:
ssh -vvv -i ~/.ssh/filename.pub USER@REMOTEHOST
# on the remote:
sudo journalctl -t sshd -n 100
Setting up a ssh-config for multiple keys / servers
In ~/.ssh/config add something like:
Host tankbox
HostName 10.0.0.9
User storage
IdentityFile ~/.ssh/tankbox
Port 2323
Host hypebox
HostName 10.0.0.8
User controller
IdentityFile ~/.ssh/hypebox
Port 22
And now instead of specifying key+user+port every time, you'd just:
ssh tankbox
# or
ssh hypebox