Thursday, October 13, 2016

how to login to ssh server using private key


1- generate key pair of public key and private key
$ ssh-keygen -f tohttpserver.key


- it will generate two files like below
tohttpserver.key  tohttpserver.key.pub

2- set permission for the privatekey
$ chmod 600 tohttpserver.key

3- copy the public keys to server,
-  if prefer auto use  command below
$ ssh-copy-id -i  tohttpserver.key.pub test@192.168.56.23

- if prefer manual, login into the server and create file, /home/test/.ssh/authorized_keys with content of the file  tohttpserver.key.pub
 and change the permission of the authorized_keys with command below

$ chmod 600 /home/test/.ssh/authorized_keys

4- to login using private key using the following command

$ ssh -i tohttpserver.key test1@192.168.56.23
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-68-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Thu Oct 13 00:42:48 2016 from

No comments:

Post a Comment