您如何防止 SourceTree/SSH 忘记您的 SSH 密钥?(我必须手动重新运行“ssh-add"才能让它再次工作!) [英] How do you keep SourceTree/SSH from forgetting your SSH keys? (I have to manually re-run 'ssh-add' to get it to work again!)

查看:36
本文介绍了您如何防止 SourceTree/SSH 忘记您的 SSH 密钥?(我必须手动重新运行“ssh-add"才能让它再次工作!)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新 - 又发生了!!!

好的,所以这再次发生了!男人真是令人沮丧!!!但这一次我挖得更深一些,发现由于某种原因,我的私钥被卸载了.

具体来说,当我称之为...

ssh-add -l -E md5

我明白了……

代理没有身份.

但是,如果我再运行这个...

ssh-add/Users/[用户名]/.ssh/[私钥]

一切恢复正常!SourceTree 连接正常.

问题是为什么我必须继续运行ssh-add"命令?!为什么它总是忘记我的钥匙?!

正如在别处提到的,不确定这是否有所不同,但我正在运行带有 High Sierra 的 MacBook Pro,尽管这也在 Sierra 上发生.

原帖:

这个让我既难倒又恼火!!SourceTree(或 ssh 或其他东西!)每天都在忘记/不应用/忽略我的 SSH 密钥!我不知道为什么.

<块引用>

注意:更新为使用 BitBucket 的信息而不是 GitHub.

这是我当前 config 文件的相关部分

# --- Sourcetree 生成 ---主机 MarqueIV-Bitbucket主机名 bitbucket.org用户 MarqueIV首选认证公钥IdentityFile/Users/MarqueIV/.ssh/MarqueIV-Bitbucket使用钥匙串 是AddKeysToAgent 是#----------------------------

这是我的 ~/.ssh 文件夹的ls"(已截断)

-rw-r--r--@ 1 MarqueIV 员工 421 Dec 14 11:25 config-rw-r--r--@ 1 MarqueIV 员工 1808 年 12 月 9 日 14:20 known_hosts-rw------- 1 MarqueIV 员工 3243 Dec 6 23:33 MarqueIV-Bitbucket-rw-r--r-- 1 MarqueIV 员工 781 Dec 6 23:33 MarqueIV-Bitbucket.pub

这是我的 known_hosts 文件(密钥已编辑)

bitbucket.org,104.192.143.3 ssh-rsa [已编辑]bitbucket.com,104.192.143.9 ssh-rsa [已编辑]104.192.143.2 ssh-rsa [已编辑]

<块引用>

注意:不确定这是否重要,但您可以看到第 1 行和第 2 行似乎是重复的.

这是 ssh -Tv git@bitbucket.org

的输出

OpenSSH_7.6p1, LibreSSL 2.6.2debug1:读取配置数据/Users/MarqueIV/.ssh/configdebug1:读取配置数据/etc/ssh/ssh_configdebug1:/etc/ssh/ssh_config 第 48 行:为 * 应用选项debug1:连接到 bitbucket.org 端口 22.debug1:连接建立.debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_rsa type -1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_rsa-cert type -1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_dsa 类型-1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_dsa-cert type -1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_ecdsa type -1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_ecdsa-cert type -1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_ed25519 类型-1debug1: key_load_public: 没有那个文件或目录debug1:身份文件/Users/MarqueIV/.ssh/id_ed25519-cert type -1debug1:本地版本字符串 SSH-2.0-OpenSSH_7.6debug1:远程协议版本2.0,远程软件版本conker_1.0.315-a08d059 app-153debug1:不匹配:conker_1.0.315-a08d059 app-153debug1:以git"身份向 bitbucket.org:22 进行身份验证debug1: SSH2_MSG_KEXINIT 发送debug1:收到 SSH2_MSG_KEXINITdebug1:kex:算法:curve25519-sha256@libssh.orgdebug1:kex:主机密钥算法:ssh-rsadebug1:kex:服务器-> 客户端密码:aes128-ctr MAC:hmac-sha2-256-etm@openssh.com 压缩:无debug1:kex:客户端-> 服务器密码:aes128-ctr MAC:hmac-sha2-256-etm@openssh.com 压缩:无debug1:期待 SSH2_MSG_KEX_ECDH_REPLYdebug1:服务器主机密钥:ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1Adebug1:主机 'bitbucket.org' 已知并且与 RSA 主机密钥匹配.debug1:在/Users/MarqueIV/.ssh/known_hosts:1 中找到密钥debug1:在 4294967296 个块后重新加密debug1: SSH2_MSG_NEWKEYS 发送debug1:期待 SSH2_MSG_NEWKEYSdebug1:收到 SSH2_MSG_NEWKEYSdebug1:在 4294967296 个块后重新加密debug1:收到 SSH2_MSG_SERVICE_ACCEPTdebug1:可以继续的身份验证:publickeydebug1:下一个身份验证方法:publickeydebug1:提供公钥:RSA SHA256:h+6zCXg32Uw4fYxSUMwYst3zee8RFb9Z47H1QUTz58E/Users/MarqueIV/.ssh/MarqueIV-GitHubdebug1:可以继续的身份验证:publickeydebug1:尝试私钥:/Users/MarqueIV/.ssh/id_rsadebug1:尝试私钥:/Users/MarqueIV/.ssh/id_dsadebug1:尝试私钥:/Users/MarqueIV/.ssh/id_ecdsadebug1:尝试私钥:/Users/MarqueIV/.ssh/id_ed25519debug1:没有更多的身份验证方法可以尝试.git@bitbucket.org:权限被拒绝(公钥).

看到它似乎没有应用在 configknown_hosts 中定义的密钥?好像会有问题吧?

<块引用>

注意:我使用的是 macOS Sierra,并且我已经更新了我的路径以在 /usr/local/bin 之前包含 /usr/bin,如此处.如果我不这样做,我会收到一条错误消息,说 ssh 无法识别配置中的 UseKeychain yes.

因此,几乎每天都是我必须经历的例行程序.我将使用 GitHub 作为我的示例.

  1. 我打开 SourceTree 并尝试从 GitHub 中提取最新版本.它因git@github.com:权限被拒绝(公钥)"而失败.消息.

  2. 我从 SourceTree 中删除了我的 GitHub 帐户.

  3. 我从我机器上的 .ssh 文件夹中删除了 GitHub 的公钥和私钥.

  4. 我转到 GitHub 并从我的帐户中删除我的旧公钥.

  5. 回到 SourceTree,我使用我的用户名和密码再次登录 GitHub.

  6. 登录后,使用 SourceTree,我为 GitHub 生成一个新的 SSH 密钥对.

  7. 我将我的公钥复制到我的 GitHub 帐户中的 SSH 区域.(有时我注意到它为我添加了它,但我喜欢安全并仔细检查.)

  8. 现在我可以再次推拉就好了.

我当天回家并在家登录.它又失败了.重复以上所有步骤.

我如何让 SourceTree/ssh/whatever 来记住我的 da*n 密钥,这样我就不必每次更改位置时都继续这样做?!我错过了什么步骤???

那么任何人都可以提供有关如何使我的 SSH 密钥保持不变"的建议吗?

解决方案

好吧,我想我已经弄清楚了所有部分.

为了帮助人们获得他们所追求的东西,这里有一个直接的解决方案:

  1. 确保您要使用的密钥受密码保护,否则它们不会添加到钥匙串中.
  2. 确保在 config 文件中配置了要自动加载的密钥,并设置了 UseKeychainAddKeysToAgent
  3. 确保从终端连接到那些配置定义的主机!!
  4. 创建一个 LaunchAgent 以运行 ssh-add -A 以自动重新加载您的钥匙串存储的密钥

好的,现在您知道该怎么做了,下面是为什么".

正如我在问题中所解释的,最近,每当我重新启动时,我(错误地)认为系统丢失了我的私钥.这不是失去他们,只是无视他们.这是因为对于像我这样从不使用 GIT 终端的人来说,一堆东西汇聚在一起,形成了一场完美的混乱风暴.

  1. 在最新版本的 macOS 中,Apple 更改了 SSH 的实现方式,以便更好地匹配 OpenSSH 的实现
  2. 由于 #1,ssh-add -K [privateKey] 不再将密钥存储在钥匙串中(它实际上忽略了 -K.)而它们确实被添加到该会话的 ssh 中——因此您的连接将再次工作——一旦您重新启动,它们将不再起作用.(这就是让我发疯的原因!)
  3. 即使对于 在 Keychain 中的密钥,Apple 也不再自动加载它们,这意味着您必须手动从终端调用 ssh-add -A 以每次重新加载它们重新启动的时间.
  4. 但是,如上所述,ssh-add -K [privateKey] 不再将密钥添加到钥匙串中,因此 ssh-add -A 无论如何对于密钥毫无意义这样补充.(可以通过其他方式将它们添加到钥匙串中.稍后会详细介绍.)

由于上述原因,在升级您的操作系统之前使用 -K 选项手动添加的任何密钥仍将在您的钥匙串中.但是,Apple 更改后添加的密钥不是.

也就是说,Apple 确实仍然能够将密钥存储在钥匙串中,但不再能够从 ssh-add 存储密钥.它现在仅适用于您的 config 文件中定义的主机.

这是现在获取钥匙串中钥匙的唯一方法.

再说一次,这是我的配置:

主机 MarqueIV-Bitbucket主机名 bitbucket.org用户 git <-- 确保这是git",而不是 SourceTree 放在这里的内容首选认证公钥IdentityFile/Users/MarqueIV/.ssh/MarqueIV-BitbucketUseKeychain 是 <-- 注意这里AddKeysToAgent 是 <-- ...这里

等等!如果您查看我的配置文件,它确实 设置了这些值!那么为什么它不起作用呢?

两件事.

  1. 我从来不使用终端.我使用的 SourceTree 不使用该文件中的主机条目
  2. 从技术上讲,Apple 仅在访问该主机时按需添加(和存储)密钥,而不是在(重新)加载文件时,这意味着除非您明确访问该主机,否则不会发生任何事情.

在我的情况下,通过 SourceTree 添加密钥会为该初始会话添加它们,但是一旦我重新启动,密钥将不会再次加载,因此所有连接都会失败.ssh-add -A 也不会修复它,因为同样,它们不在钥匙串中,这意味着我又回到了使用 ssh-add [ 在命令行上手动添加每个私钥].好痛!!

然后我想到...如果该设置在配置文件中,并且可以从命令行使用该条目,那么我不应该能够直接连接到该主机,从而将密钥添加到我的钥匙扣?让我们一探究竟吧!我输入了这个...

ssh -T MarqueIV-BitBucket

果然,密钥不仅添加到了 ssh,而且还再次添加到了我的钥匙串中!我通过直接检查钥匙串访问确认了这一点,它就在那里.

为了进一步测试,我运行了这个......

ssh-add -D

它删除了我所有的密钥.果然,我的SourceTree连接又全部失败了.

然后我运行了这个...

ssh-add -A

钥匙串存储的钥匙神奇地回来了,连接又开始工作了!哇哦!!

好的,差不多了,但不完全!重启呢?同样,Apple 不再自动从 Keychain 加载密钥.当然,现在到终端输入 ssh-add -A 只是一个快速的短途旅行,但同样,我不应该这样做!

进入 LaunchAgents!

LaunchAgents 和 LaunchDaemons 不在本文的讨论范围内,但简而言之,它们允许您在重新启动时、按计划、系统发生更改等时执行某些操作.

就我而言,我想要在我登录到我的 mac 时运行的东西,所以 LaunchAgent 是最好的选择.

这是我的 plist,定义了每次登录我的帐户时如何执行 ssh-add -A(即使我从未接触过终端):

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN""http://www.apple.com/DTDs/PropertyList-1.0.dtd><plist version=1.0"><字典><key>标签</key><string>ssh-add-a</string><key>ProgramArguments</key><阵列><string>ssh-add</string><string>-A</string></阵列><key>RunAtLoad</key><真/></dict></plist>

因为我只想要这个给我的特定用户,所以我把它存储在这里:

~/Library/LaunchAgents

<块引用>

注意:一定要把权限改成允许执行,否则启动不了!

果然,在重新启动时,我所有的键都回来了并且处于活动状态!连接一切正常,孩子们玩耍,大人哭了,这是 Code-dom 美好的一天!

总结一下:

  1. Apple 改变了 SSH 的工作方式
  2. 不再从命令行将密钥添加到钥匙串
  3. Apple 也不再自动加载存储在钥匙串中的密钥
  4. 使用终端连接到配置定义的主机已修复 #2
  5. 使用 LaunchAgent 已修复 #3

希望这有帮助!现在是时候为我酸痛的肩膀买些冰镇热药了,我一直在努力地拍拍自己以解决这一切!;)

UPDATE - It happened AGAIN!!!

Ok, so this just happened AGAIN! MAN is this frustrating!!! But this time I dug a little deeper and found that for some reason, my private keys were unloaded.

Specifically, when I call this...

ssh-add -l -E md5

I get this...

The agent has no identities.

However, if I then run this...

ssh-add /Users/[username]/.ssh/[private key]

Everything works again! SourceTree connects just as it's supposed to.

The question is why do I have to keep running the 'ssh-add' command?! Why does it keep forgetting my keys?!

As mentioned elsewhere, not sure if this makes a difference, but I'm running a MacBook Pro with High Sierra, although this happens on Sierra too.

Original Post:

This one has me both stumped, and annoyed as heck!! SourceTree (or ssh or something!) keeps forgetting/not applying/ignoring my SSH keys every day! I don't know why.

Note: Updated to use BitBucket's info instead of GitHub.

Here's the relevant portion of my current config file

# --- Sourcetree Generated ---
Host MarqueIV-Bitbucket
    HostName bitbucket.org
    User MarqueIV
    PreferredAuthentications publickey
    IdentityFile /Users/MarqueIV/.ssh/MarqueIV-Bitbucket
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

Here's a 'ls' of my ~/.ssh folder (truncated)

-rw-r--r--@ 1 MarqueIV  staff   421 Dec 14 11:25 config
-rw-r--r--@ 1 MarqueIV  staff  1808 Dec  9 14:20 known_hosts
-rw-------  1 MarqueIV  staff  3243 Dec  6 23:33 MarqueIV-Bitbucket
-rw-r--r--  1 MarqueIV  staff   781 Dec  6 23:33 MarqueIV-Bitbucket.pub

Here's my known_hosts file (keys redacted)

bitbucket.org,104.192.143.3 ssh-rsa [redacted]
bitbucket.com,104.192.143.9 ssh-rsa [redacted]
104.192.143.2 ssh-rsa [redacted]

Note: Not sure if this matters, but you can see lines 1 and 2 seem to be duplicates.

And here's the output of ssh -Tv git@bitbucket.org

OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/MarqueIV/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to bitbucket.org port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/MarqueIV/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version conker_1.0.315-a08d059 app-153
debug1: no match: conker_1.0.315-a08d059 app-153
debug1: Authenticating to bitbucket.org:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:zzXQOXSRBEiUtuE8AikJYKwbHaxvSc0ojez9YXaGp1A
debug1: Host 'bitbucket.org' is known and matches the RSA host key.
debug1: Found key in /Users/MarqueIV/.ssh/known_hosts:1
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 4294967296 blocks
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: RSA SHA256:h+6zCXg32Uw4fYxSUMwYst3zee8RFb9Z47H1QUTz58E /Users/MarqueIV/.ssh/MarqueIV-GitHub
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/MarqueIV/.ssh/id_rsa
debug1: Trying private key: /Users/MarqueIV/.ssh/id_dsa
debug1: Trying private key: /Users/MarqueIV/.ssh/id_ecdsa
debug1: Trying private key: /Users/MarqueIV/.ssh/id_ed25519
debug1: No more authentication methods to try.
git@bitbucket.org: Permission denied (publickey).

See how it doesn't appear to be applying the key defined in config and known_hosts? Seems like that would be a problem, no?

Note: I'm using macOS Sierra, and I have updated my path to include /usr/bin before /usr/local/bin as outlined here. If I don't do that, I get an error saying ssh doesn't recognize UseKeychain yes in the config.

As a result, almost daily here's the routine I have to go through. I'll use GitHub as my example.

  1. I open SourceTree and try to pull the latest from GitHub. It fails with a 'git@github.com: Permission denied (publickey).' message.

  2. I remove my GitHub account from SourceTree.

  3. I delete both the public and private keys for GitHub from the .ssh folder on my machine.

  4. I go to GitHub and delete my old public key from my account.

  5. Back in SourceTree, I log into GitHub again using my username and password.

  6. Once logged in, using SourceTree, I generate a new SSH key-pair for GitHub.

  7. I copy my public key to the SSH area in my GitHub account. (Sometimes I notice it adds it for me, but I like to be safe and double-check.)

  8. Now I can push and pull again just fine.

I go home for the day and log on at home. It fails again. Repeat all of the steps above.

How do I get SourceTree/ssh/whatever to remember my da*n keys so I don't have to keep doing this every time I change locations?! What step am I missing???

So can anyone offer suggestions on how to make my SSH keys 'stick'?

解决方案

Ok, I think I have all the parts figured out.

To help people get what they're after, here's the solution right up front:

  1. Make sure the keys you want to work with are secured with a password or else they will not add to Keychain.
  2. Make sure the keys you want to auto-load are configured in your config file and have the UseKeychain and AddKeysToAgent set
  3. Make sure to connect to those config-defined hosts from terminal!!
  4. Create a LaunchAgent to run ssh-add -A to automatically reload your Keychain-stored keys

Ok now that you know what to do, here's the 'why'.

The Meat

As explained in my question, lately, whenever I rebooted, I (incorrectly) thought the system was losing my private keys. It wasn't losing them, it was just ignoring them. This was because of a bunch of things that all came together in a perfect storm of confusion for someone like me who never uses the terminal for GIT.

  1. In the latest versions of macOS, Apple changed how it's implemented SSH so that It better matches the implementation of OpenSSH
  2. As a result of #1, ssh-add -K [privateKey] no longer stores the keys in the keychain (it essentially ignores the -K.) While they do get added to ssh for that session--and thus your connections will work again--as soon as you reboot, they will no longer work. (This is what's been driving me mad!)
  3. Even for keys that are in the Keychain, Apple no longer loads them automatically meaning you manually have to call ssh-add -A from the terminal to reload them every time you reboot.
  4. However, as stated above, ssh-add -K [privateKey] no longer adds the keys to keychain, so ssh-add -A is pointless anyway for keys added that way. (They can be added to Keychain another way. More on that in a minute.)

Because of the above, any keys manually added with the -K option prior to upgrading your OS will still be in your Keychain. However, keys added after Apple's change are not.

That said, Apple does still have the ability to store keys in the keychain, but not from ssh-add anymore. It now only works for hosts defined in your config file.

This is now the only way to get your keys in your Keychain.

Again, here's my config:

Host MarqueIV-Bitbucket
    HostName bitbucket.org
    User git <-- Make sure this is 'git', not what SourceTree puts here
    PreferredAuthentications publickey
    IdentityFile /Users/MarqueIV/.ssh/MarqueIV-Bitbucket
    UseKeychain yes    <-- Note here
    AddKeysToAgent yes <-- ...and here

But wait! If you look in my config file, it does have those values set! So why didn't it work?

Two things.

  1. I don't use Terminal, ever. I use SourceTree which doesn't use the host entry in that file
  2. Apple technically only adds (and stores) the key on demand when that host is accessed, not when the file is (re)loaded meaning unless you explicitly access that host, nothing happens.

In my case, adding the keys via SourceTree would add them for that initial session, but as soon as I rebooted, the keys would again not be loaded and thus all connections would fail. ssh-add -A wouldn't fix it either because again, they weren't in the keychain, meaning I was back to manually adding each one on the command line with ssh-add [privateKey]. What a pain!!

Then it occurred to me... if that setting is in the config file, and that entry can be used from the command line, then shouldn't I be able to directly connect to that host, thus adding the keys to my keychain? Let's find out! I typed this...

ssh -T MarqueIV-BitBucket

And sure enough, not only was the key added to ssh, but it was also again added to my Keychain! I confirmed this by checking Keychain Access directly and it was there.

To further test, I ran this...

ssh-add -D

which deleted all my keys. Sure enough, my SourceTree connections all failed again.

Then I ran this...

ssh-add -A

and the keychain-stored keys magically came back and connections started working again! WOOT!!

Ok, almost there, but not quite! What about reboots? Again, Apple no longer automatically loads keys from Keychain. Sure, it's just a quick jaunt now to terminal to type ssh-add -A, but again, I shouldn't have to do that!

Enter LaunchAgents!

LaunchAgents and LaunchDaemons are beyond the discussion of this post, but in short, they allow you to execute something on reboot, on a schedule, when changes happen to the system, etc.

In my case, I wanted something that would run when I logged onto my mac, so a LaunchAgent was the best choice.

Here's my plist defining how to execute ssh-add -A every time I logged into my account (even if I never touched Terminal):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>ssh-add-a</string>
    <key>ProgramArguments</key>
    <array>
        <string>ssh-add</string>
        <string>-A</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Since I only want this for my particular user, I stored it here:

~/Library/LaunchAgents

Note: Make sure to change the permissions to allow it to be executed, or it won't start!

Sure enough, on reboot, all my keys came back and were active! Connections all worked, children played, grown men cried, and it was a good day in the Code-dom!

So to recap:

  1. Apple changed how their SSH worked
  2. Keys were no longer added to Keychain from the command line
  3. Apple also no longer auto-loaded keys that were stored in the keychain
  4. Using terminal to connect to config-defined hosts fixed #2
  5. Using a LaunchAgent fixed #3

Hope this helps! Now time to go get some Icy-Hot for my sore shoulder that I've been patting myself on so hard for figuring this all out! ;)

这篇关于您如何防止 SourceTree/SSH 忘记您的 SSH 密钥?(我必须手动重新运行“ssh-add"才能让它再次工作!)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆