Saturday, June 28, 2008

'publickey' SSH Authorization fails if 'authorized_keys' file is writable by non-owners

I didn't realize this. SSH kept prompting me to fill in password even though I forced it to use just 'publickey' authorization:

$ ssh -i id_kimmy somewhere.com -v
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/yclian/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/yclian/.ssh/identity
debug1: Trying private key: /home/yclian/.ssh/id_dsa
debug1: Next authentication method: password
yclian@somewhere.com's password:

ssh -i id_kimmy somewhere.com -o 'PreferredAuthentications publickey' -v
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /home/yclian/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/yclian/.ssh/identity
debug1: Trying private key: /home/yclian/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey,password).

Fixed by revoking write permissions (chmod 700) to the authrozied_keys file. Very simple logic, brrr.

Some links that I came across:

- yc

No comments: