Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to SSH Login Without Password [closed]

Tags:

ssh

ksh

ssh-keys

To use sftp in a script without user interaction (non-interactive). For example to login to an anonymous ftp server and not have to manually.

like image 833
Arun Antony Avatar asked Dec 08 '10 14:12

Arun Antony


2 Answers

On your computer

cd ~/.ssh
ssh-keygen -t dsa

press the enter key at every prompt

Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
ad:98:43:13:c9:ea:66:8e:d0:d9:66:59:d8:3a:f7:29
The key's randomart image is:
+--[ DSA 1024]----+
|                 |
|     . .         |
|      +          |
|     + . .       |
|    o = S .      |
| . + = + .       |
|. o @ = .        |
| . B oEo .       |
|  . .  .o        |
+-----------------+

you will get 2 files id_dsa and id_dsa.pub use scp or other utility to copy file to your server

scp ~/.ssh/id_dsa.pub user@host:~/.ssh/

On your server

Add the new key to the file ~/.ssh/authorized_keys.

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

Finally change the access modes;

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Verify that access mode is correct for ~

ls -ld ~

if not, you can use

chmod 700 ~

to correct your home access.

Logout and login again

like image 106
E.G. Avatar answered Oct 19 '22 04:10

E.G.


Type the following commands

  1. ssh-keygen

    Press Enter key till you get the prompt

  2. ssh-copy-id -i root@ip_address

    (It will once ask for the password of the host system)

  3. ssh root@ip_address

    Now you should be able to login without any password

like image 38
Ravindra Avatar answered Oct 19 '22 06:10

Ravindra