User Tools

Site Tools


connect_via_ssh_key

How to use ssh key to connect server/client/remote

On the client : - Prepare folder if isn't -

$mkdir ~/.ssh
$chmod 700 ~/.ssh
$cd ~/.ssh

- Create a ssh key (if you don't have one !) -

$ssh-keygen -t rsa -C "id_rsa"

- Copy your pub certificate to remote -

$scp -p id_rsa.pub remoteuser@remotehost


On remote (server or other client) :

- Connect to your remote server/client -

$ssh remoteuser@remotehost

- Prepare folder -

$mkdir ~/.ssh
$chmod 700 ~/.ssh

- Copy the key into a authorized file -

» IMPORTANT «

You need to edit the authorized_keys on the right user, if you need to allow multiple user, you need to edit all “.ssh\authorized_keys” under all users !!

$touch ~/.ssh/authorized_keys
$cat id_rsa.pub >> ~/.ssh/authorized_keys
$chmod 600 ~/.ssh/authorized_keys

Remove password authentication and allow ssh connect RSA

Personally, i use webmin for do this :

but you can download the pdf of howtoforge if you want to do this manually :ssh_key_connect.pdf

Connect with a ssh key

$chmod -R 600(or 700 ?) id_rsa.priv.txt
$ssh -i id_rsa.priv root@IP


Source : howtoforge


- created date : 2017.02.22 - - modified date : 2018.06.15 -

connect_via_ssh_key.txt · Last modified: 2018/06/15 16:15 by admin