Skip to content

Instantly share code, notes, and snippets.

@sdntechforum
Last active February 22, 2023 19:23
Show Gist options
  • Save sdntechforum/b76ae280de6361851ecab1e935f8fc26 to your computer and use it in GitHub Desktop.
Save sdntechforum/b76ae280de6361851ecab1e935f8fc26 to your computer and use it in GitHub Desktop.
This document describe how to distribute and add multiple SSH security keys to the server so they can talk to each other

step 1: Create a new rsa key pair of your choice locally on you device.

ssh-keygen -t rsa

step 2 : once you have Public and private key pair available, chnage their permissions. The private key need a permission of 400 and set Public key permission as 644.

sudo chmod 600 id_rsa
sudo chmod 644 id_rsa.pub

step 3: Use SCP or SFTP protocol to connect to remote server and transfer the Pub/Private keypair to ".ssh directory". In the same directory you can fine "authorized_keys" file which has the current Public key.

step 4: Now Go to .ssh Directory and concatenate the new public key to authorized_keys file.

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

step 5: Very the new key added to authorized_keys by open reading the file.

cat authorized_keys

Repeate the steps 3 - 5 on other Server where you want to distrubute the same key pair. After that both the server will havce a commnon set of RSA keypair and you can use the private key to ssh to other devuces where the poublic key is already available.

remote-server1$ ssh -i id_rsa.pub user@remoteserver2
@sdntechforum
Copy link
Author

commit one

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