- Create new ssh key
Change to ssh directory
cd ~/.ssh/
Create a new key. Give it a useful name (you are prompted for a name after you hit enter; leave passphrase blank)
ssh-keygen -t ed25519 -C "your_email@example.com"
or if no Ed25519 algo:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- Copy key to server
ssh-copy-id -i ~/.ssh/my_key.pub username@ip_address_of_server
- Update
~/.ssh/config
file
Host first-hop
HostName login-node-dns-or-ip
User username
IdentityFile ~/.ssh/my_key
IdentitiesOnly yes
ForwardAgent yes
Host second-hop
HostName second-hostname-or-ip
User username
IdentityFile ~/.ssh/my_key
ProxyCommand ssh first-hop -W %h:%p
- If needed
chomd
the newly created key to 600
chmod 600 my_key_name