15

Steps

  1. Open PuTTY on my Windows desktop.
  2. SSH into my MacBook Pro.
  3. cd to a github clone
  4. $ git push

Expected

Everything up-to-date

Actual

Enter passphrase for key '/Users/whit537/.ssh/github':

Notes

  • The github key is listed in Keychain Access.
  • I can show its passphrase in Keychain Access.
  • I can use this passphrase successfully at the prompt in PuTTY.
  • I get the expected result at a Terminal window on the MacBook.
  • uname -a: Darwin chad.whitacre 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386

Updates

2011-04-12: I discovered the security tool via a question in the Related sidebar (didn't notice it in the list of possible answers when posting). I tried running security unlock-keychain but I get the same result. It seems as though there should be some way to do this. There are two keys in question, actually, and these are long passphrases, not short passwords, and I need them frequently during the day. So I have some incentive to get to the bottom of this.

2011-04-13: This sounds promising. I see the /tmp/launch-*****/Listeners file on the MacBook. Next time I am on the PC I'll try setting SSH_AUTH_SOCK in my PuTTY session. If that works once I'll see about a .profile hook to discover the current launch session automatically.

1

3 Answers 3

23

You should be able to unlock your keychain in the Terminal like this:

security unlock-keychain -p <YourPassword> ~/Library/Keychains/login.keychain

If you do not want to be prompted for the password you can store the password in a file and then execute the command like this:

security unlock-keychain -p `cat ~/.file_with_your_password` ~/Library/Keychains/login.keychain

Please note that storing your keychain password in a file has some security-related drawbacks as you can imagine so you have to decide for yourself if this is an option for you.

I Hope this helps

3
  • 3
    "some" indeed, doesn't putting the password to access your keychain in plaintext in a file kinda make the whole thing pointless...? Then you could as well have the stuff that is protected in the keychain in plaintext, too?
    – tml
    Dec 12, 2012 at 12:18
  • ...then follow with this answer
    – techraf
    Jun 1, 2016 at 0:45
  • You can leave off the -p <YourPassword> part and it will prompt you for your password. That would probably be the best option. At least it does in 2022, it may not have in 2011
    – CWSpear
    Nov 6, 2022 at 5:46
4

Your keychain is tied to the graphical login of OS X. When you log in to the computer locally it opens your keychain. Terminal, with bash running inside it, is aware of your keychain.

When you log in remotely through PuTTY your keychain doesn't get opened, and PuTTY and bash do not know of it - even if you are logged in locally as well. The link between them just isn't there.

So I'm sorry, but when you log in through PuTTY you are stuck with having to enter the password.

That is unless someone who knows the internals of the OS X keychain system can come up with some way to manually put that link in place within your PuTTY connected session, but that to my mind is probably more work than typing in a password once in a while.

1
  • 1
    These are long passphrases for a couple keys that I use frequently, so I have some incentive to discover the linking mechanism of which you speak.
    – whit537
    Apr 13, 2011 at 17:41
2

As I describe in this answer, you need to also run

eval `ssh-agent -s`

in addition to unlocking the keychain.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .