sorry for my typos. Your public key file should be authorized_keys. But unfortunately I was not able to write it correctly anywhere :(
Main Topics
Browse All TopicsI am trying to set up an SFTP to a server without being prompted for a password. This SFTP will run in a batch C-shell script. The server I am SFTPing to is using Open SSH. I did the following steps: 1) generated a public key using ssh-keygen -t dsa 2) copied the public key to the remote host under the ./ssh directory 3) copied the id_dsa.pub to authorized_keys file. I then ran the C-shell script (listed below in the Code section) but I am prompted for the password. How can I get this script to run without being prompted for a password? Thanks in advance for your help.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi. I'm not sure I understood your message completely.
This is from the receiving side:
st93% pwd
/apps/websvcs/docs/helpdes
st93% ls -l
total 24
-rw------- 1 ent_ahd hdext 607 Aug 21 16:24 authorized_keys
-rw------- 1 ent_ahd hdext 668 Aug 21 16:20 id_dsa
-rw------- 1 ent_ahd hdext 607 Aug 21 16:20 id_dsa.pub
st93%
This is from the sending side:
CSCESERV6-NEW:ahduser /home/ahduser/.ssh% ls -l
total 5
-rw------- 1 ahduser dba 668 Aug 21 11:08 id_dsa
-rw------- 1 ahduser dba 607 Aug 21 11:08 id_dsa.pub
-rw-r--r-- 1 ahduser dba 419 Aug 20 11:09 known_hosts
And here is my attempt at SFTP, which once again results in my being prompted for a password:
CSCESERV6-NEW:ahduser /home/ahduser/.ssh% sftp ent_ahd@pub01.rsc.raytheon
Connecting to pub01.rsc.raytheon.com...
Password:
Hi,
What I wanted to say is your home directory .ssh permisison should be 700 so that :
cd
ls -ald .ssh
will produce:
drwx------ 1 ahduser dba 668 Aug 21 11:08 .ssh
id_dsa is for the sending side. All you need is id_dsa.pub attaced to authorized_keys at the receiving end. So delete id_dsa.* from receiving end.
BTW you should make sure that /apps/websvcs/docs/helpdes
I've retried it over my system:
[root@host1 .ssh]# ls -al
total 40
drwx------ 2 root root 4096 Aug 17 21:28 .
drwxr-x--- 27 root root 4096 Aug 21 19:08 ..
-rw------- 1 root root 392 Jul 19 00:08 authorized_keys
-rw------- 1 root root 2443 Aug 22 02:35 known_hosts
[root@host1 .ssh]# sftp root@host2
Connecting to host2...
sftp>
If you have access check the /etc/ssh/sshd_config file on the remote machine and check it has the following entry / value, if it's no you can't use key's, till it's tweaked:
PubkeyAuthentication yes
also on the remote server do a:
chmod go-w $HOME
As a group or other body could rename the .ssh directory to say .wibble and create a new.ssh with there own keys in, if the HOME directory has write permissions. So ssh won't play if it's tweakable.
Thanks for the answers. We're still trying to get SFTP to work without prompting for a password. I use the same technique on other servers and SFTP works fine without prompting for a password. On the server I'm going to now, I see no /etc/ssh/sshd_config file which may be causing the problem. The server admin is looking into it.
Hi,
Your home directory of : /apps/websvcs/docs/helpdes
finger sftp_user
and the home directory indicated is /apps/websvcs/docs/helpdes
Cheers,
K.
Here's the home directory and variables:
st93% finger ent_ahd
Login name: ent_ahd In real life: Thinh Chu
Directory: /apps/websvcs/docs/helpdes
On since Aug 25 15:39:11 on pts/2 from zlbac846920.dhcp.ess.us.ra
15 seconds Idle Time
No unread mail
No Plan.
st93%
st93% pwd
/apps/websvcs/docs/helpdes
st93% ls -l
total 24
-rwx------ 1 ent_ahd hdext 2424 Aug 25 15:42 authorized_keys
-rw------- 1 ent_ahd hdext 607 Aug 25 11:25 id_dsa.pub
-rw-r--r-- 1 ent_ahd hdext 635 Aug 25 15:40 known_hosts
st93%
st93% cat authorized_keys
ssh-dss AAAAB3NzaC1kc3MAAACBAOx7o5
Uiz5BB9FXi+7+VE3CbUqZsv/e/
/mUNYLrM/bZEFOI2gUN5zyawqT
s1HzuWBTgWMhr8kaCrs8hTLL5K
MBwh2RFtql0NXQS8eQpFogKlv3
3WLAVfPhS+8AAACBALaMl+4Elh
J2R2YCtbR5YQDpGsoGXjQCod86
ibejWOJ0uxgx3hrFbyvAYl4Bws
ssh-dss AAAAB3NzaC1kc3MAAACBAOx7o5
Uiz5BB9FXi+7+VE3CbUqZsv/e/
/mUNYLrM/bZEFOI2gUN5zyawqT
s1HzuWBTgWMhr8kaCrs8hTLL5K
MBwh2RFtql0NXQS8eQpFogKlv3
3WLAVfPhS+8AAACBALaMl+4Elh
J2R2YCtbR5YQDpGsoGXjQCod86
ibejWOJ0uxgx3hrFbyvAYl4Bws
ssh-dss AAAAB3NzaC1kc3MAAACBAKBbH+
layYlXgFqeANND2fxyy135VA63
vckutXadWOxQOqy4etgOWzBv+2
WSS/Kt/1F8CB1iIJCBIVj0L/WS
6piZLUhZVn4jprmcBFQuV393+9
6Csw0sPE1AAAAIB1j5+XBsr4GK
Yepaf0vBM+xl7sECEX1pud9mBf
fqgRbcbVWEfz2CTRK2BVBrgwuA
st93% env
HOME=/apps/websvcs/docs/he
PATH=/usr/bin:
Als oneed to do the same for: /apps/websvcs/docs/helpdes
the Home directory should be owned and only writable by the user e.g.
drwxr-xr-x 52 ent_ahd hdext 4096 2009-08-25 21:44 ent_ahd
If not, per my earlier post: chmod go-w $HOME
If stil having problems on the remote server type: ssh -vvv localhost
In the output you should see the enables authentication methods, if you don't see publickey it's the ssd configuration e.g.
debug1: Authentications that can continue: publickey,password,keyboar
debug3: start over, passed a different list publickey,password,keyboar
debug3: preferred publickey,keyboard-interac
debug3: authmethod_lookup publickey
To arober11:
on the ssh -vw localhost, I received the following:
OpenSSH_4.5p1, OpenSSL 0.9.8d 28 Sep 2006
To KeremE:
Here are the uname -a from both sides:
(sending server)
CSCESERV6-NEW:% uname -a
AIX csceserv6 3 5 0002B14A4C00
CSCESERV6-NEW:%
(receiving server)
st93% uname -a
SunOS st93 5.8 Generic_117350-62 sun4u sparc SUNW,UltraAX-i2
st93%
to arober11:
(I'm not sure this is the correct ssh -vvv)
csceserv6-new:ssh -vvv 147.16.195.26
OpenSSH_4.5p1, OpenSSL 0.9.8d 28 Sep 2006
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Failed dlopen: /usr/krb5/lib/libkrb5.a(li
load module /usr/krb5/lib/libkrb5.a(li
0509-026 System error: A file or directory in the path name does not exi
st.
debug1: Error loading Kerberos, disabling Kerberos auth.
debug2: ssh_connect: needpriv 0
debug1: Connecting to 147.16.195.26 [147.16.195.26] port 22.
debug1: Connection established.
debug1: identity file /home/ent_ahd/.ssh/identit
debug1: identity file /home/ent_ahd/.ssh/id_rsa type -1
debug3: Not a RSA1 key file /home/ent_ahd/.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 /home/ent_ahd/.ssh/id_dsa type 2
debug1: Remote protocol version 1.99, remote software version OpenSSH_4.5
debug1: match: OpenSSH_4.5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.5
debug2: fd 4 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-excha
roup-exchange-sha1,diffie-
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfi
28,arcfour256,arcfour,aes1
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfi
28,arcfour256,arcfour,aes1
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ri
ssh.com,hmac-sha1-96,hmac-
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ri
ssh.com,hmac-sha1-96,hmac-
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: diffie-hellman-group-excha
roup-exchange-sha1,diffie-
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfi
28,arcfour256,arcfour,aes1
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfi
28,arcfour256,arcfour,aes1
tr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ri
ssh.com,hmac-sha1-96,hmac-
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ri
ssh.com,hmac-sha1-96,hmac-
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_REQUES
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 115/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 /home/ent_ahd/.ssh/known_h
debug3: check_host_in_hostfile: filename /etc/ssh/ssh_known_hosts
debug3: check_host_in_hostfile: filename /home/ent_ahd/.ssh/known_h
debug3: check_host_in_hostfile: filename /etc/ssh/ssh_known_hosts
debug2: no key of type 0 for host 147.16.195.26
debug3: check_host_in_hostfile: filename /home/ent_ahd/.ssh/known_h
debug3: check_host_in_hostfile: filename /etc/ssh/ssh_known_hosts2
debug3: check_host_in_hostfile: filename /home/ent_ahd/.ssh/known_h
debug3: check_host_in_hostfile: filename /etc/ssh/ssh_known_hosts
debug2: no key of type 2 for host 147.16.195.26
The authenticity of host '147.16.195.26 (147.16.195.26)' can't be established.
RSA key fingerprint is 06:54:77:03:8d:6e:be:6e:0d
Are you sure you want to continue connecting (yes/no)?yes
Warning: Permanently added '147.16.195.26' (RSA) to the list of known hosts.
debug2: bits set: 516/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/ent_ahd/.ssh/identit
debug2: key: /home/ent_ahd/.ssh/id_rsa (0)
debug2: key: /home/ent_ahd/.ssh/id_dsa (20070698)
debug1: Authentications that can continue: publickey,password,keyboar
ve
debug3: start over, passed a different list publickey,password,keyboar
ive
debug3: preferred publickey,keyboard-interac
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,passw
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Hitting here in public key auth ssh clienti&&&&&&&&&&&&&&&
debug1: Trying private key: /home/ent_ahd/.ssh/identit
debug3: no such identity: /home/ent_ahd/.ssh/identit
debug1: Hitting here in public key auth ssh clienti&&&&&&&&&&&&&&&
debug1: Trying private key: /home/ent_ahd/.ssh/id_rsa
debug3: no such identity: /home/ent_ahd/.ssh/id_rsa
debug1: Offering public key: /home/ent_ahd/.ssh/id_dsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboar
ve
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
debug1: Authentications that can continue: publickey,password,keyboar
ve
debug3: userauth_kbdint: disable: no info_req_seen
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred:
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
ent_ahd@147.16.195.26's password:
debug3: packet_send2: adding 64 (len 58 padlen 6 extra_pad 64)
debug2: we sent a password packet, wait for reply
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug3: ssh_session2_open: channel_new: 0
debug2: channel 0: send open
debug1: Entering interactive session.
debug2: callback start
debug2: client_session2_setup: id 0
debug2: channel 0: request pty-req confirm 0
debug3: tty_make_modes: ospeed 9600
debug3: tty_make_modes: ispeed 0
debug3: tty_make_modes: 1 3
debug3: tty_make_modes: 2 28
debug3: tty_make_modes: 3 8
debug3: tty_make_modes: 4 21
debug3: tty_make_modes: 5 4
debug3: tty_make_modes: 6 0
debug3: tty_make_modes: 7 0
debug3: tty_make_modes: 8 17
debug3: tty_make_modes: 9 19
debug3: tty_make_modes: 10 26
debug3: tty_make_modes: 11 25
debug3: tty_make_modes: 12 18
debug3: tty_make_modes: 14 22
debug3: tty_make_modes: 30 1
debug3: tty_make_modes: 31 0
debug3: tty_make_modes: 32 0
debug3: tty_make_modes: 33 0
debug3: tty_make_modes: 34 0
debug3: tty_make_modes: 35 0
debug3: tty_make_modes: 36 1
debug3: tty_make_modes: 37 0
debug3: tty_make_modes: 38 0
debug3: tty_make_modes: 39 0
debug3: tty_make_modes: 40 0
debug3: tty_make_modes: 41 1
debug3: tty_make_modes: 50 1
debug3: tty_make_modes: 51 1
debug3: tty_make_modes: 52 0
debug3: tty_make_modes: 53 1
debug3: tty_make_modes: 54 1
debug3: tty_make_modes: 55 1
debug3: tty_make_modes: 56 0
debug3: tty_make_modes: 57 0
debug3: tty_make_modes: 58 0
debug3: tty_make_modes: 59 1
debug3: tty_make_modes: 60 1
debug3: tty_make_modes: 61 1
debug3: tty_make_modes: 62 0
debug3: tty_make_modes: 70 1
debug3: tty_make_modes: 71 0
debug3: tty_make_modes: 72 1
debug3: tty_make_modes: 73 0
debug3: tty_make_modes: 74 0
debug3: tty_make_modes: 75 0
debug3: tty_make_modes: 90 1
debug3: tty_make_modes: 91 1
debug3: tty_make_modes: 92 0
debug3: tty_make_modes: 93 0
debug2: channel 0: request shell confirm 0
debug2: fd 4 setting TCP_NODELAY
debug2: callback done
debug2: channel 0: open confirm rwindow 0 rmax 32768
debug2: channel 0: rcvd adjust 131072
3 unsuccessful login attempts since last login.
It seems that your key is havinga wrong format
it didn't like the key. This is not a public-key this is an SSL-Certificate !!!
Will you please generate new keys ??
Here's a link on how -to :http://www.experts-exchan
Thanks, on the csceserv6-new server can you please do a:
ls -ld /home/ent_ahd/
ls -la /home/ent_ahd/.ssh/
The home directory (ent_ahd) should have permissions: drwxr-xr-x
The .ssh directory (.) should have the following permissions: drwx------
And your id_dsa should have permissions: -rw-------
Also on the csceserv6-new server can you do a:
cd /home/ent_ahd/.ssh/
cat id_dsa.pub >> authorized_keys
ssh -vvv localhost
You should then be able to login back into that box without a password.
Repeat this exercise on the Solaris box, once you can "ssh -vvv localhost" on the othee box try connection from csceserv6-new to the other server.
debug3: Not a RSA1 key file /home/ent_ahd/.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 /home/ent_ahd/.ssh/id_dsa type 2
This shows that you have an invalid privte key this is why you can not use it to match it with remote public key.
Cheers,
Business Accounts
Answer for Membership
by: KeremEPosted on 2009-08-21 at 15:13:42ID: 25156350
Hi,
File permissions are very critical for SSH. So your $HOME/.ssh directory shouls exactly 700 for file permissions. your authorized.keys should be have 600 as file permissions. You don't need the private key there. Remaove all files there but authorized_skes which includeds your id_dsa.pub. You need id_dsa at the sending end. This dile should have 600 file permissions and your .ssh directory should have 700 file permissions too. Otherwise your keys will be rejected during the initial contact and you'll left-off with password authentications.
Cheers,
K.