Thursday | 25 APR 2024
[ previous ]
[ next ]

Notes on SSH

Title:
Date: 2022-09-18
Tags:  

Table of Contents

  1. Troubleshooting

You can generate a public and private key easily.

ssh-keygen
# ssh-keygen.exe

This will prompt for a filename and will create 2 files, the private key and the public key. The public key will be filename.pub.

mv vscode_rsa ~/.ssh

Add a configuration to ~/.ssh/config.

Host 192.168.13.12
    HostName 192.168.13.12
    User nivethan
    ForwardAgent yes
    PreferredAuthentications publickey
    IdentityFile "C:\Users\nivethant\.ssh\vscode_rsa"

Now on the server, you need to add the public key to ~/.ssh/authorized_keys.

Copy the public key to the server and then run the command below.

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

Now you can use ssh on the client machine and it will automatically connect using the keys.

ssh 192.168.13.12

Troubleshooting

If you get a permission denied issue, then it might be permissions on one of the folders is incorrect.

chmod 755 /home/nivethan
chmod 700 /home/nivethan/.ssh
chmod 600 /home/nivethan/.ssh/*