-
Notifications
You must be signed in to change notification settings - Fork 13
27348363: Mac OS X 10.12: ssh-agent does not automatically load passphrases on the keychain during startup #15361
Comments
Confirmed that this problem still exists in OSX 10.12 GM Candidate |
According to https://twitter.com/lorentey/status/753581927412686850's interaction with Apple this is now the expected behaviour. Basically the |
In the past, when you'd create an ssh-agent it would automatically load all keys from the keychain. I use a utility that creates separate agents for each key that I use, so I don't forward personal agents to work servers (for example), and the utility had to start an agent then delete all unexpected keys from it. With this change, I just start an agent and add the desired agent with Overall, this is probably a good change. |
Dunno about this... this was also present in last year's beta (10.11) and was fixed in the first bugfix release after launch. |
running |
You should be able to do an ssh-add -A (Add identities to the agent using any passphrases stored in your keychain.). -K is to store it to keychain the first time. |
This kinda sucks if this was intentional behavior. I liked not having to think about it between reboots. I hope they fix this. |
Some things that look like they could be helpful: I'm going to try the |
I've found that the best way (for me) to deal with this is to execute a script upon opening a terminal window/tab. I use iTerm2, which does this automatically for me. The script simply runs a basic command: ssh-add -K ..... followed by each key that I need to have available whilst in a terminal session. |
I just ran into ssh-agent problems with a new mac running El Cap. I can't use donCarlosOne's solution because my keys have passphrases. Basically, as far as I can tell, launchd is not starting an ssh-agent process at login - so I don't have the env var SSH_AUTH_SOCK set, so nothing can talk to the agent from my login process tree. I have no idea why it's not starting and providing the socket info. This is utterly maddening - I don't care about between reboots (although I'd like the Keychain to mean I don't need to re-add keys to the damn agent) but the agent won't run at all now. It runs if I start it manually with launchctl start, but of course the launchctl getenv SSH_AUTH_SOCK is still null. AIIIGH. Currently troling the net looking for a fix that doesn't involve installing an entire new openssh setup via brew. |
@jbz when you do and not sure your problem is related to this thread, ssh_agent should still be using the mac os x keychain (which is what we are talking about), something else is wrong for you =( |
Yeah, something else is wrong. Sorry, shouldn't have threadjacked. I found a hackaround. |
Found this issue searching for what I'd hoped would be a solution better than mine. I put this in my
Now my key gets silently added on every new login shell. If you previously did |
The above solution by @JJJ, while functional, slows down the loading of each new shell session by 2-3 seconds as the keys are reloaded. Anyone have any ideas for only loading it on the first new login session? As it stands this will launch and detach the subprocess so your prompt promptly appears:
However, this means that on your first login session, your keys aren't instantly ready, and also that it's still (somewhat inefficiently) run on each new login session in the background. Another alternative could be a launchd script that runs on login, which might be pretty bulletproof, but is also a bit complicated to set up. Maybe a quick-bootstrap script would be in order. Edit: looks like @joshbuchea's answer directly below is the one. Restarted and all keys were loaded appropriately. Great! |
This solution may be a bit naive, but I was able to restore pre macOS Sierra
Optionally replace References: I summarized this information in a blog post. Critiques and alternative solutions welcome! |
Can confirm @joshbuchea's solution works, and it appears that you do not need to |
This seems to have only worked until I rebooted, so I assume as soon as the agent shut down this stopped working. Tried @joshbuchea's solution, and it's working so far ( |
Also confirming that @joshbuchea's solution works in |
@joshbuchea's is what I was hoping to find. Thanks! The key bit is:
DerailingYou're all already using Now mine starts like:
...which lets all of my other connections look like:
...and ensures all subsequent connections go through the proxy server first, and none of the servers behind the proxy need to be publicly accessible through SSH. Then I can Single point of failure? Sure, but I think it's better than having a bunch of publicly open SSH ports, or remembering what port numbers you tried to obfuscate them to. /derail, and thanks again for this @joshbuchea |
@joshbuchea's solution worked great for me as well. Thanks for posting! |
Out of interest, Many users here have indeed reported that
The question I than have is, where is it going instead because the passphrase is still somehow magically stored given that some of the above solutions work... also for me, creating an ssh config file restores the expected behaviour so |
I confirm @joshbuchea's solution works! I'm running Mac OS X Sierra 10.12.2 (16C68) |
I can also confirm @joshbuchea's solution works in Mac OS X Sierra 10.12.2 |
@KrisJanssen it seems to be stored in a sqlite3 database at |
@mgrandi very cool, thanks for the tip! |
See description and solution(?) here: lionheart/openradar-mirror#15361
Refs: lionheart/openradar-mirror#15361 (#issuecomment-270242512)
👍 - @joshbuchea's solution worked for me, too... OSX Sierra 10.12.3 |
When I tried the following
I get
Anyone else having the issue on El Capitan, 10.11.16? |
i see the same error as above |
@woniesong92 and @suresh7745 those two options are not available on El Capitan. Run |
I added I commented it out and now just run Anyone else experienced a similar issue with |
@o6uoq you have to also add
|
@les-okta I had that set, as below:
..but I commented out |
They have to be on separate lines, like my example above. |
@les-okta they are, that was just a typo above - same problem. |
@les-okta
I've noticed I have two paths where ssh, ssh-add and ssh-agent are stored:
and apparently they are of different versions, because
tells me there is no option -- K, meanwhile
works with no issues. UpdateIt turned out in
|
After doing if [[ $- = *i* ]]; then
declare -i __agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?)
if [ "$SSH_AUTH_SOCK" -a $__agent_run_state -eq 1 ]; then
ssh-add -A
fi
unset __agent_run_state
fi You will want to make sure that the key paths are absolute in your keychain. |
@nalexn You probably have another installation of SSH (perhaps via MacPorts or Homebrew). Instead of updating the symlinks, uninstall the other installation (which is wherever those symlinks pointed to). That should remove the symlinks themselves as well. If it doesn't, you can simply remove them yourself, and then the SSH executables in /usr/bin will become the first ones on your PATH, and you'll use them by default. |
I had to |
Thanks for this @joshbuchea @chaintip! |
@joshbuchea has claimed the |
Thanks for the BCH @tea-spoon! 🙏 |
@woniesong92 |
Does anyone have this successfully working with |
@o6uoq looks like above ^^ @RyanHendry-awin needed to uninstall OpenSSH via Brew to resolve:
|
Description
Summary:
In previous versions of macOS, ssh-agent used to remember the passphrases for the keys I added to the keychain with “ssh-add -K ”. After a reboot (or logout/login), it automatically picked up the passphrases from the keychain with no extra step.
In Sierra, I have to manually poke the agent to recognize there are passphrases on the keychain.
Steps to Reproduce:
Expected Results:
The agent should automatically load keys whose passphrases it can access on the keychain.
Actual Results:
I need to manually poke the agent after each logout/login.
Regression:
This used to be automatic before the Sierra betas. On one of my secondary Macs running El Capitan, ssh-agent still remembers SSH keys across reboots, with no special configuration (as far as I can tell).
Notes:
Here is a metadata dump of the two passphrase entries on my keychain. Keychain access shows that their ACLs always allow access to “ssh-agent”, “ssh-add” and “ssh”.
$ security find-generic-password -s "SSH" -a "/Users/lorentey/.ssh/id_rsa"
keychain: "/Users/lorentey/Library/Keychains/login.keychain-db"
version: 512
class: "genp"
attributes:
0x00000007 ="SSH: /Users/lorentey/.ssh/id_rsa"
0x00000008 =
"acct"="/Users/lorentey/.ssh/id_rsa"
"cdat"=0x32303130303932343138333830345A00 "20100924183804Z\000"
"crtr"=
"cusi"=
"desc"=
"gena"=
"icmt"=
"invi"=
"mdat"=0x32303130303932343138333830345A00 "20100924183804Z\000"
"nega"=
"prot"=
"scrp"=
"svce"="SSH"
"type"=
$ security find-generic-password -s "SSH" -a "/Users/lorentey/.ssah/git-fusion"
keychain: "/Users/lorentey/Library/Keychains/login.keychain-db"
version: 512
class: "genp"
attributes:
0x00000007 ="SSH: /Users/lorentey/.ssh/git-fusion"
0x00000008 =
"acct"="/Users/lorentey/.ssh/git-fusion"
"cdat"=0x32303133313131353130353430335A00 "20131115105403Z\000"
"crtr"=
"cusi"=
"desc"=
"gena"=
"icmt"=
"invi"=
"mdat"=0x32303133313131353130353430335A00 "20131115105403Z\000"
"nega"=
"prot"=
"scrp"=
"svce"="SSH"
"type"=
Product Version: Mac OS X 10.12 (16A239j)
Created: 2016-07-14T14:01:35.005190
Originated: 2016-07-14T16:01:00
Open Radar Link: http://www.openradar.me/27348363
The text was updated successfully, but these errors were encountered: