Skip to content

Instantly share code, notes, and snippets.

@mshannaq
Created February 27, 2024 21:30
Show Gist options
  • Save mshannaq/9d17d5a94997318d967739ebc46f5a44 to your computer and use it in GitHub Desktop.
Save mshannaq/9d17d5a94997318d967739ebc46f5a44 to your computer and use it in GitHub Desktop.
create ssh key to access linux servers
how to create ssh key to access linux servers using key
@mshannaq
Copy link
Author

on your computer to create ssh key run

ssh-keygen -t rsa -b 4096 -C "[email protected]" -f  ~/.ssh/my_custom_key

change [email protected] to your email and my_custom_key to the key name

then choose Passphrase

aftetr that you can copy the public key into the linux server that you want to access using that key by running the command on your computer

ssh-copy-id -i ~/.ssh/samextendy_key.pub -p 8888 root@serverhostname

change samextendy_key.pub with the public ket file name , and change 8888 to the correct linux server ssh port , and change serverhostname with the correct hostname of your linux server.

after that to connect to the server using the key use the commmand

ssh -p 8888 serverhostname -l root -i ~/.ssh/my_custom_key

and then you will be able to connect using ssh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment