From local machine to git server

Open terminal in local machine and execute commands below:

ssh-keygen -t rsa -b 4096 -f ~/.ssh/gitkey
touch ~/.ssh/config

Open config file.

nano ~/.ssh/config

Add the following into config file. Then press ‘Ctrl + x’, then press ‘Y’ and press ‘Enter’ to save the changes.

Host github.com
HostName github.com
IdentifyFile ~/.ssh/gitkey

Modify the permission to config file.

chmod 600 ~/.ssh/config

View contain of file. Then copy the ssh key.

cat ~/.ssh/gitkey.pub

Add copied ssh key to git server.
After setup ssh key in git server, execute command below to test the connection between local machine and git server.

ssh -T git@github.com

From linux server to git server

Open new terminal and login to linux server by execute command below

ssh <USER>@<SERVER_IP>
ssh-keygen -t rsa -b 4096

View contain of file. Then copy the ssh key.

cat ~/.ssh/id_rsa.pub

Add copied ssh key to git server.
After setup ssh key in git server, execute command below to test the connection between linux server and git server.

ssh -T git@github.com

From local machine to linux server

Go to terminal in local machine and execute command below:

ssh-keygen -t rsa -b 4096 -f  ~/.ssh/linuxkey

Execute command below and copy ssh key

cat ~/.ssh/linuxkey.pub

Go to terminal which already login to linux server, execute command below:

nano ~/.ssh/authorized_keys

Paste copied ssh key and save the changes. After that, execute command below:

chmod 600 ~/.ssh/authorized_keys

After all, open new terminal and try to login from local machine to linux server to test the connection

ssh <USER>@<SERVER_IP> -i ~/.ssh/linuxkey
ssh -T git@github.com

Leave a comment

Your email address will not be published. Required fields are marked *