Skip to content

Instantly share code, notes, and snippets.

@mort3za
Created December 28, 2022 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mort3za/7829f923e2f7b15415d23fec2faf616f to your computer and use it in GitHub Desktop.
Save mort3za/7829f923e2f7b15415d23fec2faf616f to your computer and use it in GitHub Desktop.
How to login to a Linux server with a second ssh key
# generate your new ssh key (e.g. id_rsa_second)
ssh-keygen
# add the public key to server manually (from your host panel) or by:
ssh-copy-id -i ~/.ssh/id_rsa_second.pub root@server_ip_address_here
vim ~/.ssh/config
# enter this code:
Host server_ip_address_here
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa_second
# now login to server
ssh root@server_ip_address_here
# no password is required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment