Howto Linux / UNIX setup SSH with DSA public key authentication (password less login)

by Vivek Gite on May 22, 2007 · 45 comments

Q. How do you set-up SSH with DSA public key authentication? I have Linux laptop called tom and remote Linux server called jerry. How do I setup DSA based authentication so I don’t have to type password?

A. DSA public key authentication can only be established on a per system / user basis only i.e. it is not system wide. You will be setting up ssh with DSA public key authentication for SSH version 2 on two machines:

#1 machine : your laptop called tom
#2 machine : your remote server called jerry

Command to type on your laptop/desktop (local computer)

First login to local computer called tom and type the following command.

Step #1: Generate DSA Key Pair

Use ssh-keygen command as follows:
$ ssh-keygen -t dsa
Output:

Enter file in which to save the key (/home/vivek/.ssh/id_dsa):  Press [Enter] key
Enter passphrase (empty for no passphrase): myPassword
Enter same passphrase again: myPassword
Your identification has been saved in /home/vivek/.ssh/id_dsa.
Your public key has been saved in /home/vivek/.ssh/id_dsa.pub.
The key fingerprint is:
04:be:15:ca:1d:0a:1e:e2:a7:e5:de:98:4f:b1:a6:01 vivek@vivek-desktop

Caution: a) Please enter a passphrase different from your account password and confirm the same.
b) The public key is written to /home/you/.ssh/id_dsa.pub.
c) The private key is written to /home/you/.ssh/id_dsa.
d) It is important you never-ever give out your private key.

Step #2: Set directory permission

Next make sure you have correct permission on .ssh directory:
$ cd
$ chmod 755 .ssh

Step #3: Copy public key

Now copy file ~/.ssh/id_dsa.pub on Machine #1 (tom) to remote server jerry as ~/.ssh/authorized_keys:
$ scp ~/.ssh/id_dsa.pub user@jerry:.ssh/authorized_keys

Command to type on your remote server called jerry

Login to your remote server and make sure permissions are set correct:
$ chmod 600 ~/.ssh/authorized_keys

Task: How do I login from client to server with DSA key?

Use scp or ssh as follows from your local computer:
$ ssh user@jerry
$ ssh user@remote-server.com
$ scp file user@jerry:/tmp

You will still be asked for the passphrase for the DSA key file each time you connect to remote server called jerry, unless you either did not enter a passphrase when generating the DSA key pair.

Task: How do I login from client to server with DSA key but without typing a passhrase i.e. password-less login?

Type the following command at shell prompt:
$ exec /usr/bin/ssh-agent $SHELL
$ ssh-add

Output:

Enter passphrase for /home/vivek/.ssh/id_dsa: myPassword
Identity added: /home/vivek/.ssh/id_dsa (/home/vivek/.ssh/id_dsa)

Type your passhrase once. Now, you should not be prompted for a password whenever you use ssh, scp, or sftp command.

If you are using GUI such as Gnome use the command:
$ ssh-askpass
OR
$ /usr/lib/openssh/gnome-ssh-askpass

To save your passphrase during your GNOME session under Debian / Ubuntu, do as follows:
a) Click on System
b) Select Preferences
c) Select Session
d) Click on New
e) Enter "OpenSSH Password Management" in the Name text area
f) Enter /usr/lib/openssh/gnome-ssh-askpass in the command text area.
Howto Linux / UNIX setup SSH with DSA public key authentication
g) Click on close to save the changes
h) Log out and then log back into GNOME. After GNOME is started, a dialog box will appear prompting you for your passphrase. Enter the passphrase requested. From this point on, you should not be prompted for a password by ssh, scp, or sftp.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 45 comments… read them below or add one }

1 Kiran May 23, 2007

Try ssh-copy-id to copy your keys ,,,

Reply

2 sudhanshu July 28, 2010

#ssh-copy-id -i //to copy your keys
Insted of DSA key RSA is very strong so always prefer RSA key

Reply

3 ricc May 31, 2007

Vivek,

A small suggestion. Instead of

scp ~/.ssh/id_dsa.pub user@jerry:.ssh/authorized_keys

It is better to copy it in some other name and append the contents of the authorized_keys file with the contents of the id_dsa.pub file.

This way if there are any existing keys in the file, it will not get overwritten.

ricc

Reply

4 nixcraft May 31, 2007

Kiran and ricc.

Good suggestions.

Appreciate your posts!

Reply

5 Edmund June 14, 2007

Hi,
I am trying to connect from a UNIX machine to a Windows SSH server without a password entry.
I tried the steps above but I have no luck in doing it.
Any suggestions?

Reply

6 Pat September 26, 2007

It works as fine as clear it is…..

Thanks

Reply

7 vishwa December 10, 2007

I have tried this several times. Doesent seem to work. What am I missing. Can some one try it out on the same m/c with two different a/cs and confirm it again.

Reply

8 BlackNight December 21, 2007

Thanks. Useful.

Reply

9 Ali Saeed January 20, 2008

Hi Experts,

password less login information is really helpful however it does not fullfil my requirement.

I have more than 200 machines in my network running linux and I want to be able to ssh to each one of them using thier IP address from a file and then run some commands inside each and then log out.

Now, using key-gen is not practical for me and I do not want to install the “expect” utility due to some reason.

Please tell me if there is any way to supply ssh password using bash scripting? I know supplying the password in script might not be very secure, but still I want to do it this way. I shall be greatful to any help.

Regards, R.

Reply

10 Amit September 19, 2008

well there is no such need of doing login and executing commands u can just send the commands to the other machines
eg

ssh -i publicKeyFile 192.168.XXX.XXX “poweroff”

just put this in loop and put some variable for XXX values which has to be modified in each iteration based on your network IP addresses.

Reply

11 John October 24, 2008

This command needs to be executed on Tom. It think that’s where some might have gotten confused when trying to do no password.

$ exec /usr/bin/ssh-agent $SHELL
$ ssh-add

Reply

12 Balakumar January 16, 2009

Thank U so Much for nice Post

Reply

13 Gautham February 13, 2009

Really very useful & Cristal clear explanation…!

Thanks for sharing your knowledge…!

Reply

14 Merhan March 26, 2009

In the 3rd step, before you execute the following command:
scp ~/.ssh/id_dsa.pub user@jerry:.ssh/authorized_keys
you need to make sure that the home dir in jerry (remote computer) has a .ssh folder. Other wise, you need to create this folder in the remote computer before executing the above command.

Reply

15 Nazooran March 28, 2009

Dear Experts,

I have one HP and other Solaris, say hp1 and sol1
Created DSA key in hp1 populated public key to sol1 and appended in authorized_keys
But while I am doing ssh it is asking password.
During troubleshooting it was showing the following output:
bash$ sftp -v -v -v m1user@sol1
Connecting to sol1…
OpenSSH_4.3p2-hpn, OpenSSL 0.9.7i 14 Oct 2005
HP-UX Secure Shell-A.04.30.000, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug3: RNG is ready, skipping seeding
debug2: ssh_connect: needpriv 0
debug1: Connecting to sol1 [10.23.45.67] port 22.
debug1: Connection established.
debug1: identity file /batch/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /batch/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type ‘—–BEGIN’
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type ‘—–END’
debug3: key_read: missing keytype
debug1: identity file /batch/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1
debug1: no match: Sun_SSH_1.1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3p2-hpn
debug2: fd 5 setting O_NONBLOCK
debug3: RNG is ready, skipping seeding
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-gro
up14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour1
28,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-c
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour1
28,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-c
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@open
ssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@open
ssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==,diffie-hellm
an-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes128-cbc,arcfour,3des-cbc,blowfish-cbc
debug2: kex_parse_kexinit: aes128-ctr,aes128-cbc,arcfour,3des-cbc,blowfish-cbc
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: none,zlib
debug2: kex_parse_kexinit: i-default
debug2: kex_parse_kexinit: i-default
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 142/256
debug2: bits set: 506/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /batch/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /batch/.ssh/known_hosts
_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host ‘sol1′ is known and matches the RSA host key.
debug1: Found key in /batch/.ssh/known_hosts:1
debug2: bits set: 514/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /batch/.ssh/known_hosts/id_rsa (0)
debug2: key: /batch/.ssh/known_hosts/id_dsa (4002ecf8)
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publicke
y,password,keyboard-interactive
debug3: start over, passed a different list gssapi-keyex,gssapi-with-mic,publick
ey,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /batch/.ssh/known_hosts/id_rsa
debug3: no such identity: /batch/.ssh/known_hosts/id_rsa
debug1: Offering public key: /batch/.ssh/known_hosts/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publicke
y,password,keyboard-interactive
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:

Please provide your feed back

Thanks in advance
Nazoor

Reply

16 Milan May 27, 2009

I’ve set up ssh with DSA public key authentication to be able to scp without a password. I’ve got a script that I run from a Red Hat Linux box (v.4 64-bit) that uses scp to copy a couple of files to a Solaris box, which works fine without a password. (It also works copying to a Mac OSX box.) However, the exact same script doesn’t work when I try to call it from a cron job.

The relevant differences of the very verbose log files from (1.) the successful commmand-line scp and (2.) the failed cron job scp are below. Do you have any ideas of how to get my cron scp job to work? I notice that the unsuccessful script run from the cron job looks in .sssh/identity and .ssh/id_rsa first (for a private key?) before looking in .ssh/id_dsa. Though the script run from the cron job eventually accepts the public key, the PEM_read_PrivateKey fails immediately thereafter and the copy fails. Conversely, and successfully, the same script called from the command line checks in .ssh/id_dsa first and succeeds with the publickey authentication (without ever looking at .ssh/identity and .ssh/id_rsa twice!) I’d very much appreciate any help you may be able to lend. Thanks very much.

1. Successful scp called from command-line script

Executing: program /usr/bin/ssh host test.ucsd.edu, user Foobar, command scp -v -p -t /Users/Foobar/Documents
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
. . .
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/Foobar/.ssh/id_dsa (0x. . .)
debug2: key: /home/Foobar/.ssh/identity ((nil))
debug2: key: /home/Foobar/.ssh/id_rsa ((nil))
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-with-mic
debug2: we sent a gssapi-with-mic packet, wait for reply
debug1: Miscellaneous failure
Unknown code krb5 195
debug1: Trying to start again
debug2: we sent a gssapi-with-mic packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Offering public key: /home/Foobar/.ssh/id_dsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-dss blen 433
debug2: input_userauth_pk_ok: fp 3f:4a:64: . . .
debug1: Authentication succeeded (publickey).
. . .
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.1 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0

2. Unsuccessful scp called from cron-job script

Executing: program /usr/bin/ssh host test.ucsd.edu, user Foobar, command scp -v -p -t /Users/Foobar/Documents
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
. . .
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/Foobar/.ssh/identity ((nil))
debug2: key: /home/Foobar/.ssh/id_rsa ((nil))
debug2: key: /home/Foobar/.ssh/id_dsa (0x. . .)
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug1: Next authentication method: gssapi-with-mic
debug2: we sent a gssapi-with-mic packet, wait for reply
debug1: Miscellaneous failure
Unknown code krb5 195
debug1: Trying to start again
debug2: we sent a gssapi-with-mic packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive
debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Trying private key: /home/Foobar/.ssh/identity
debug1: Trying private key: /home/Foobar/.ssh/id_rsa
debug1: Offering public key: /home/Foobar/.ssh/id_dsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-dss blen 433
debug2: input_userauth_pk_ok: fp 3f:4a:64: . . .
debug1: PEM_read_PrivateKey failed
. . .
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive).
lost connection

Reply

17 Paul Beyer June 18, 2009

@ Milan:

I had the same problem but was able to rectify it by adding option -i to my scp command and pointing it to my user’s identify file like so:

scp -B -i /home/my_user filename_to_transfer.txt my_user@remote.host:

I think that without specifying my_user’s identify file, it default’s to the cron user’s which would could an authentication failure.

Hope this helps.

Reply

18 Milan June 18, 2009

Paul,

Thanks for the suggestion, which I’m guessing just might do the trick. I think I tried using -B without luck but I didn’t try -i. Coincidentally, I finally resolved the impasse just yesterday by giving up on DSA and switching to RSA authentication! Thanks again for the very relevant help.

Reply

19 Brian A July 16, 2009

I have followed these steps to the letter, and I am still getting these errors:

satwasdev01[/home/mvnuser/.ssh]$ ssh -vvv -i /home/mvnuser/.ssh/id_dsa.pub ic>
OpenSSH_4.6p1 (CentrifyDC build 3.0.7-745), OpenSSL 0.9.8e (CentrifyDC build 3.0.7-745) 23 Feb 2007
debug1: Reading configuration data /etc/centrifydc/ssh/ssh_config
debug1: Applying options for *
debug3: RNG is ready, skipping seeding
debug2: ssh_connect: needpriv 0
debug1: Connecting to icosqas2 [10.9.245.67] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /home/mvnuser/.ssh/id_dsa.pub.
debug1: identity file /home/mvnuser/.ssh/id_dsa.pub type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.6
debug1: match: OpenSSH_4.6 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.6
debug2: fd 3 setting O_NONBLOCK
debug1: Miscellaneous failure
No credentials cache found
debug1: Miscellaneous failure
No credentials cache found
debug3: RNG is ready, skipping seeding
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: gss-gex-sha1-toWM5Slw5Ew8Mqkay+al2g==,gss-group1-sha1-toWM5Slw5Ew8Mqkay+al2g==,gss-group14-sha1-toWM5Slw5Ew8Mqkay+al2g==,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_init: found hmac-md5
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_init: found hmac-md5
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 138/256
debug2: bits set: 492/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/mvnuser/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /home/mvnuser/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug1: Host 'icosqas2' is known and matches the RSA host key.
debug1: Found key in /home/mvnuser/.ssh/known_hosts:1
debug2: bits set: 482/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/mvnuser/.ssh/id_dsa.pub (2005c358)
debug3: input_userauth_banner
This is a protected computer system. Unauthorized access is prohibited. This computer system including all related equipment, networks, and network devices is provide only for authorized Harland Clarke use.  Harland Clarke computer systems may be monitored for lawfull purposes, including approved Harland Clarke security testing.  Use of this Harland Clarke computer system authorized or unauthorized constitutes consent to monitoring of this system. Unauthorized use may subject you to criminal prosecution.
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-keyex
debug3: remaining preferred: gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-keyex
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug2: we did not send a packet, disable method
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Miscellaneous failure
No credentials cache found
debug1: Miscellaneous failure
No credentials cache found
debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/mvnuser/.ssh/id_dsa.pub
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
mvnuser@icosqas2's password:

Please help!!

Reply

20 arun July 22, 2009

I installed OpenSSH on my windows PC (jerry here).
I have a unix box (tom here).
I’ve done all the steps mentioned here.
But when i’m trying to sftp from the unix box to the Windows PC, it is again asking for password.
Is this because the remote server is a windows pc with openSSH installed on it?
Kindly help.

Reply

21 biswa July 29, 2009

I trying to login from a solaris box(local machine : daytona) to solaris box(remote machine : voltest).
my username in daytona : bpadhy
i tried to login to the voltest using the below command
sftp beaadm@10.188.45.136
but it still asks for password.

Can anyone help me in this regard.

Reply

22 Neetu August 17, 2009

Hi, I followed the exact steps and in the same session I was able to do a password less login. But when I opened a new session, I couldnt do it until I again typed:
$ exec /usr/bin/ssh-agent $SHELL
$ ssh-add

Do I need to type this in every new session? If yes, then it doesnt serve the purpose.

Reply

23 Vivek Gite August 17, 2009

@Neetu, use keycahin.

Reply

24 German M September 3, 2009

Excelent tip, thanks!

Reply

25 Bubnoff September 24, 2009

It should be pointed out that the tutorial, as is, will NOT work with backup scripts which
is probably the primary reason many of us came to this link. This will allow you to log in
during a session without a password.

There needs to be clear instructions on scripting and backups using keys for this tutorial
to ROCK. Great information and I don’t mean to be course or an ungrateful bastard, this is a great site …however. Do we need keychain for this functionality? I hope the answer is no because keychain is a PITA.

Thanks ~

Bub

Reply

26 Dhananjay October 6, 2009

Hi I have two machine from machine 1 Ima trying to do password less ssh to machine 2, generated a dsa key on machine 1 user/.ssh folder. I got private and publick dsa keys there. copied the content of pub key file and paste it to machine2 user/.ssh folder authorized_key file in the end.
but now when trying to login from machine 1 to machine 2 it asks for password, verbose mode gives below in short.

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /var/smarthkp/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug1: Offering public key: /var/smarthkp/.ssh/id_dsa_s3c
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: gssapi-keyex,gssapi-with-mic,publickey,password,keyboard-interactive
debug1: Trying private key: /var/smarthkp/.ssh/identity
debug3: no such identity: /var/smarthkp/.ssh/identity
debug1: Trying private key: /var/smarthkp/.ssh/id_rsa
debug3: no such identity: /var/smarthkp/.ssh/id_rsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
Password:

Please help….

Reply

27 Zack January 20, 2010

I followed the procedure and its perfect.
I have another question.
Requirements: I want to assign my root account with a DSA key so that only with that specific DSA
can use the root account
How can I achieve this?

Thanks

Reply

28 Ashok March 3, 2010

Thank you very much for the post.
I have followed the same steps above given but still client is prompting for the password.

Pls help

Thanks in advance.

Reply

29 Umesh March 8, 2010

Hi ,

Even i followed same step but it worked from for first time but 1 week that my backup was not happening ,,then when i checked i was not able to login to remote system without password …

And regenerated the key also but still not working .. But from the remote system to local machine its working ,, wat may be the fundAA!!!!!!!!!!!..

Reply

30 Ashok April 13, 2010

While generating the key donot put any passphrase, just press ENTER.
then does not prompt for password.
it worked for me.

Reply

31 Asher April 16, 2010

Hi it works fine for me ,but everytime i close the putty and try to do scp again it asks for the passphrase again .so each time i login afresh i have to start the ssh-agent and the ssh-add
….like i m wondering if there is a better way to do it?

Reply

32 Sajid May 17, 2010

Excellent article, Vivek, many thanks.

Reply

33 Yuan Sun July 28, 2010

I saw the program. Run the following commands to deal with it.

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

Reply

34 yoachan October 27, 2010

I feel like an idiot.
chmod 600 ~/.ssh/authorized_keys solved the problem, meanwhile I have 2 other machine that have no problem with 755 permission…

Thanks :)

Reply

35 Abhay Shah January 2, 2011

We wish to devlope the software with cd-lock protection.
- there is 90 days validity.
- Cd copy is not possible.
- Installation process
- Automatic System key generate.
- Provide registration key via Phone on basis of System key.

Reply

36 pieter February 2, 2011

And for those of you on hp-ux 11.31, (or other O/Ses) resist the tempation to add these lines into your .bashrc / ,bash_profile, because you will, like me, lock yourself out :-

exec /usr/bin/ssh-agent $SHELL
ssh-add

Shame :(

Reply

37 aks August 23, 2011

But in this case it will prompt you for the passphrase while refreshing the .profile!!

Reply

38 shilpa February 14, 2011

While transferring the files from one server to another, if the file contains a colon(:) then it is assuming the file name before colon as server name and giving the error “host nor service provided, or not known”

For ex: scp -pq copy:temp.txt user@server:/home/user/bin/.

If the file name is “s:temp.txt”, it is taking “copy” as server name… Any suggestions on how to resolve this issue?

Reply

39 Vivek Gite February 14, 2011
scp -pq ./copy:temp.txt user@server:/home/user/bin/

Reply

40 ASAmauri June 5, 2011

Hi all,

It was very usefull for me and should say: God Blesses you!

Thanks, many thanks!!!

Hug.

Reply

41 Niranjana June 9, 2011

Hi,

I am connecting to a Linux machine using the sftp2 command to fetch a file.I have followed these steps but it still asks for a password.

Please reply to this query

Reply

42 Kundan July 30, 2011

Thankx…
Realy it helps me alot while connecting remote user with no password…
now its working……. :)

Reply

43 Binoy July 15, 2011

Thanks for this post. Saved me!

Reply

44 Jass August 4, 2011

In my case, even after removing all the files in ‘.ssh’ folder in both client and server, the ssh works perfectly. Can someone explain about this?

Reply

45 Pavan October 28, 2011

Hi,
I have setup the SSH keys for passwordless login as u mentioned above. But when I use the automated sftp script in crontab it fails when executed manually it executes.

Please let me know what might be the issue.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 5 + 15 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the simple math so we know that you are a human and not a script.



Previous post:

Next post: