System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

User-id with chroot prompt for password!

Ahmed_58
Regular Advisor

User-id with chroot prompt for password!

Dears,
I setup a sftp/scp user using chroot script to limite access and use only for file transfer...with below steps. everything works perfect, only one problem, it is prompting for password! although I use the key-gen.

1. SSH version must be 5.10.x and above
2. use chroot to create the sftp/scp user
3. change /etc/passwd to include /./
4. after using chroot,,, remeber to restart ssh

Regards,
Ahmed
14 REPLIES
Ivan Krastev
Honored Contributor

Re: User-id with chroot prompt for password!

Enable more detailed logging in ssh daemon to see what is error denying direct access without password. In most cases this is file/directory permissions.

regards,
ivan
Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

Ivan,
I still can't figure out where is the problem....

$ sftp -vvv machnet@bat-bc2
Connecting to bat-bc2...
OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5, OpenSSL 0.9.7m 23 Feb 2007
HP-UX Secure Shell-A.05.10.006, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug3: Seeding PRNG from /opt/ssh/libexec/ssh-rand-helper
debug2: ssh_connect: needpriv 0
debug1: Connecting to bat-bc2 [10.3.4.17] port 22.
debug1: Connection established.
debug3: Not a RSA1 key file /home/machnet/.ssh/id_rsa.
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
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
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/machnet/.ssh/id_rsa type 1
debug1: identity file /home/machnet/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.2p1+sftpfilecontrol-v1.3
debug1: match: OpenSSH_5.2p1+sftpfilecontrol-v1.3 pat OpenSSH*
debug1: Remote is NON-HPN aware
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5
debug2: fd 4 setting O_NONBLOCK
debug3: RNG is ready, skipping seeding
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: AUTH STATE IS 0
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,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,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: 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-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,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_setup: found hmac-md5
debug1: REQUESTED ENC.NAME is 'aes128-cbc'
debug1: kex: server->client aes128-cbc hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: REQUESTED ENC.NAME is 'aes128-cbc'
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: 521/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug3: check_host_in_hostfile: filename /home/machnet/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 1
debug3: check_host_in_hostfile: filename /home/machnet/.ssh/known_hosts
debug3: check_host_in_hostfile: match line 2
debug1: Host 'bat-bc2' is known and matches the RSA host key.
debug1: Found key in /home/machnet/.ssh/known_hosts:1
debug2: bits set: 490/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/machnet/.ssh/id_rsa (40031c98)
debug2: key: /home/machnet/.ssh/id_dsa (0)
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug3: start over, passed a different list publickey,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: Offering public key: /home/machnet/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/machnet/.ssh/id_dsa
debug3: no such identity: /home/machnet/.ssh/id_dsa
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:
Aneesh Mohan
Honored Contributor

Re: User-id with chroot prompt for password!

Hi Ahmed,

Please re-generate the ssh key in the client server and copy id_rsa.pub on the destination server $HOME/.ssh/authorized_keys.

/opt/ssh/bin/ssh-keygen -t rsa


Regards,
Aneesh

Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

Hi Aneesh,

still the same,.... asking for password.

Ahmed
Aneesh Mohan
Honored Contributor

Re: User-id with chroot prompt for password!

Hi Ahmed,

Could you please post

a)
#sftp -v machnet@bat-bc2

b)on client machine
$ cat id_rsa.pub

c)on bat-bc2
$cat authorized_keys


Regards,
Aneesh
Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

HI Aneesh,..

$ sftp -v machnet@bat-bc2
Connecting to bat-bc2...
OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5, OpenSSL 0.9.7m 23 Feb 2007
HP-UX Secure Shell-A.05.10.006, HP-UX Secure Shell version
debug1: Reading configuration data /opt/ssh/etc/ssh_config
debug1: Connecting to bat-bc2 [10.3.4.17] port 22.
debug1: Connection established.
debug1: identity file /home/machnet/.ssh/id_rsa type 1
debug1: identity file /home/machnet/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.2p1+sftpfilecontrol-v1.3
debug1: match: OpenSSH_5.2p1+sftpfilecontrol-v1.3 pat OpenSSH*
debug1: Remote is NON-HPN aware
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: AUTH STATE IS 0
debug1: REQUESTED ENC.NAME is 'aes128-cbc'
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: REQUESTED ENC.NAME is 'aes128-cbc'
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
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'bat-bc2' is known and matches the RSA host key.
debug1: Found key in /home/machnet/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering public key: /home/machnet/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password,keyboard-interactive
debug1: Trying private key: /home/machnet/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Password:
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4fqnijOjAg9IX4FOrBJ7mi1nLVSEV96vNthjHbprm+NiQHP1LEsaUMA5VRlEFE5QpYvYIM02s1MiuScRDfeuQtP0PwVdBNhZzfUw6rVh1V6FCr1PV7a/ZjcpqbyLZRdXMrWMyjdMd1v1Sp+gnsJ8afUg4K5SjRgmvWAN3nQHmhc1N7YGk6/tRQpg4J0CcjIGg2sAApwhcpzhPrdikDk7ItMItpTIOJLW8B4JWoP3B/jJv3XQgt9Nj9ALx5jWOOl6BQA2s35AL6a+KLeByvyV28QzUFhUiJ2srJi8iY9gc/qhzDq9C3Yquob2Y+JF+tLpAXUL8zW//0sXmC24ksXElQ== machnet@bat-fms1
------------------------------------

# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA4fqnijOjAg9IX4FOrBJ7mi1nLVSEV96vNthjHbprm+NiQHP1LEsaUMA5VRlEFE5QpYvYIM02s1MiuScRDfeuQtP0PwVdBNhZzfUw6rVh1V6FCr1PV7a/ZjcpqbyLZRdXMrWMyjdMd1v1Sp+gnsJ8afUg4K5SjRgmvWAN3nQHmhc1N7YGk6/tRQpg4J0CcjIGg2sAApwhcpzhPrdikDk7ItMItpTIOJLW8B4JWoP3B/jJv3XQgt9Nj9ALx5jWOOl6BQA2s35AL6a+KLeByvyV28QzUFhUiJ2srJi8iY9gc/qhzDq9C3Yquob2Y+JF+tLpAXUL8zW//0sXmC24ksXElQ== machnet@bat-fms1

Regards,
Ahmed
Ganesan R
Honored Contributor

Re: User-id with chroot prompt for password!

Hi Ahmed,

Most of the time it would be the permission issue. Make sure the following permission for password less login should work.

Users home directory should have 755 permission
$HOME/.ssh directory should have 700 permission
$HOME/.ssh/authorized_keys file should have 600 permission
Best wishes,

Ganesh.
Aneesh Mohan
Honored Contributor

Re: User-id with chroot prompt for password!

Hi Ahmed,

I feel the problem is just because of the version mismatch.

I can see on client you have version
OpenSSH_5.1p1+sftpfilecontrol-v1.2-hpn13v5 on client.

I suggest you can upgrade to the latest version 5.2 on client and re-generate the keys should work.

You can download the 5.2 version from the below link.

http://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=T1471AA


Regards,
Aneesh
Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

Hi,
Permissions checked all OK. but still getting prompt for password.

Regards,
Ahmed
Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

Hi Aneesh,
upgrade done as you suggested, and now bove are same level. BUT STILL THE SAME.

Regards,
Ahmed
Steven Schweda
Honored Contributor

Re: User-id with chroot prompt for password!

> debug3: Not a RSA1 key file /home/machnet/.ssh/id_rsa.
> debug2: key_type_from_name: unknown key type '-----BEGIN'

This looks as if you're trying to use a key
file in SSH2 format with OpenSSL software.

> [...] I use the key-gen.

Not a useful description of what you did or
where you did it.

> Please re-generate [...]

> debug1: Next authentication method: publickey
> debug1: Offering public key: /home/machnet/.ssh/id_rsa
> debug1: Authentications that can continue: publickey,password,keyboard-interactive
> debug1: Trying private key: /home/machnet/.ssh/id_dsa
> debug1: Next authentication method: keyboard-interactive

Apparently, someone does not like your (new?)
key data. Knowing nothing about how or where
your keys were generated, it's hard to guess
where you went wrong. It's also not entirely
clear to me what the OS or SSH/SFTP software
is on both of the systems involved.

There are already dozens of "SSH (or SFTP)
doesn't work" threads in this forum. You
might do a search, and then read through some
of them.


> In most cases this is file/directory
> permissions.

> Most of the time it would be the permission
> issue.

In my experience, in most cases where the
problem is permissions, some error message
mentions permissions.

> I feel the problem is just because of the
> version mismatch.

The "version mismatch" with what?

Perhaps your keyboard or display is dirty.
Either would seem to be about as likely as a
"version mismatch" to cause a problem like
this.
Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

Hi,

The userid "machnet" I'm using the home directory is linked to another directory:

lrwxr-xr-x 1 root sys 22 Jul 15 09:50 machnet -> /appl/rate/DanNet/home

And that directory has permission:
drwxrwxrwx 17 machnet users 16384 Jul 20 14:22 home

And in that directory .ssh directory has permission:
drwx------ 2 machnet users 8192 Jul 20 11:03 .ssh

And in .ssh permissions for key...:
-rw-r--r-- 1 machnet users 1013 Jul 20 13:23 authorized_keys

hope all permissions are clear.
Ahmed
OldSchool
Honored Contributor

Re: User-id with chroot prompt for password!

ONE:

"And that directory has permission:
drwxrwxrwx 17 machnet users 16384 Jul 20 14:22 home"


NO...755 there, as noted above. If you can't set it that way, look at

"StrictModes no" in the sshd_config file. That will loosen the requirement, but reduces security.



TWO:
If you're still getting this:

debug2: key_type_from_name: unknown key type '-----END' debug2: key_type_from_name: unknown key type '-----BEGIN'

then you still have an issue with the keys or whatever created them.
Ahmed_58
Regular Advisor

Re: User-id with chroot prompt for password!

Thanks to all,....
finally I manage to solve it, I remove the link directory and use the directory need for files to transfer to as a home directory.

As most of you mention it is to do with permission, hope the debuging be improve to show this kind of errors.

Regards,
Ahmed