7

I've never seen this window when doing ssh over the terminal, but now I'm using a python script that does ssh over the paramiko python module and I'm asked to provide a password (that I don't remember setting) in order to unlock the private key username@hostname. I tried my root password but it won't work.

The entire window says:

Enter password to unlock the private key

An application wants access to the private key 'user@host' , but it's locked

What is this password? I've never needed it.

6

This is your SSH private key's password.

When you created your SSH key, you may have been queried to enter a password used to encrypt it and keep it secure.

Usually, when you SSH into a server using this private key, the SSH daemon retrieves the decryption password from your keychain, where it's usually stored. Because you're using something that doesn't directly use the SSH daemon, it's likely that it wants you to re-authenticate for security purposes.

If you don't remember your password, it will be stored in your system keychain. To read this, simply go into your "Passwords and Keys" program. From there, go to the login keychain. Look for the entry for "Unlock Password for user@host". Your password will be there.

3
  • But the strange thing is that I didn't specify any private key in my code, it was supposed to connect using only password Feb 26 '17 at 19:56
  • 1
    @GuerlandoOCs The private key is (by default) read from ~/.ssh/id_rsa on most systems. When SSH connects to a server, it will attempt to go through key-based authentication and then fall back to password. Ideally, you'd just use key-based authentication because passwords over SSH is really insecure.
    – Kaz Wolfe
    Feb 26 '17 at 19:59
  • What's the "Passwords and Keys" program?
    – Moberg
    Nov 12 at 14:01
5

According to this SO Q&A - How to ssh connect through python Paramiko with public key

paramiko uses OpenSSH format keys. and it expect to get encrypted key as input so you also need to decrypt the key first.

  • Here you can see how to use putty in order to convert your PGP key into OpenSSH key format:

    To create a valid DSA format private key supported by Paramiko in Puttygen. Click on Conversions then Export OpenSSH Key

  • Here you can find simple python script which uses the key and paramiko.

1
  • Thanks! I also discovered that ssh.connect(ip,port=port,username=username,password=password,allow_agent=False,look_for_keys=False) will work. Those flags will tell it to stop Feb 26 '17 at 20:18
1

Enter the "pass phrase" that you entered when generating the key.

1
  • 1
    passphrasethat should be the correct answer because it is applicable to all situation, not only to paramiko. I ran into the same issue trough aws-cognito connection. And solved with my passphrase created during the ssh-keygen process
    – zwitterion
    Feb 1 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.