Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, i am a bit baffled with the utilization of passphrase. I have created passphrase for a user using ssh-keygen -b 2048 -t rsa. After that i copied the public key to the target server that i want to access and for the first 2 times it prompted for the passphrase. However, after that it no longer prompts for passphrase, it started to prompt for password again. Any idea why? Is there something that i have to configure or set to ensure that it always uses the key instead of prompting for password? Thank you.
It sounds like you're talking about using OpenSSH - is that right? If so, can you try to connect again with ssh -vvv instead of just ssh and post the output as well as any messages from /var/log/messages (and /var/log/secure and /var/log/syslog if they contain useful data).
debug1: Offering public key: /home/sysu/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password,keyboard-interacti
ve
debug1: Trying private key: /home/sysu/.ssh/id_dsa
debug3: no such identity: /home/sysu/.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
debug1: Authentications that can continue: publickey,password,keyboard-interacti
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
It seems that it can't find the correct key. what does that mean?
Mine is different at the point shown in red:
Code:
debug1: Authentications that can continue: publickey,keyboard-interactive
debug3: start over, passed a different list publickey,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/steve/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 149
debug2: input_userauth_pk_ok: fp 90:a8:9b:c8:75:ae:d1:7e:56:e8:1e:65:fc:72:49:3f
debug3: sign_and_send_pubkey
debug1: PEM_read_PrivateKey failed
debug1: read PEM private key done: type <unknown>
Enter passphrase for key '/home/steve/.ssh/id_rsa':
My first thought is to check the permissions of your .ssh directory and keys. I use 0700 for ~/.ssh and 0600 for the files inside it.
Are there any error messages in /var/log/messages, /var/log/secure or /var/log/syslog?
Hi gilead, thank you so much for your reply. You have solved it!!! I guess there were two problems: the ownership of the file authorized_keys was wrong, it belonged to root. Secondly, i readded the key back into the file authorized_keys again and it works. The key will never expire right? Meaning, will it like become "deactivated" after some time and you need to kinda "refresh" it by readding it into authorized_keys file again?
gilead, sorry to inform but again i have the same error on another machine but this time all the two steps that i took on the previous server do not work here anymore The output message from -vvv option is similar, debug1: Offering public key: /home/sysu/.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
Any other suggestions? permission and ownership has been set, the key has been sent over the second time too. Did i miss out anything? No error message in messages and secure file.
If you've confirmed permissions and ownership, then it's worth checking the following:
- Is it definitely the correct key?
- Was it transferred via a windows box at any point? (windows line endings are different to linux)?
- Can you start the server in debug mode and see if any more info gets printed at the server end?
There's some info about troubleshooting here and here that might help.
Geeez thank you so much gilead. I found a few possible causes to that problem, in the sshd_config file in the authentication section. I commented out lines on RSAAuthentication, PublicKeyAuthorization and AuthorizedKeyFile. now it works, thanks once again gilead.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.