在macOS> = 10.13中检索ssh密码

This is working in macOS < 10.13 via command line:

$ security find-generic-password -s "SSH" -a "/Users/<user>/.ssh/id_rsa" 

Or using this go snippet (using https://github.com/keybase/go-keychain):

usr, _ := user.Current()
dir := usr.HomeDir
keyPath, err := filepath.Abs(filepath.Join(dir, ".ssh/id_rsa"))
if err != nil {
        log.Fatal(err)
}
keyPassword, err := GetGenericPassword("SSH", keyPath, "", "")
if err != nil {
        log.Fatal(err)
}
fmt.Printf("keyPassword = %s
", keyPassword)

In macOS High Sierra this has been changed, doesn't work via command line also can't make it to work trying this:

keyPassword, err := keychain.GetGenericPassword("OpenSSH", keyPath, "SSH: "+keyPath, "com.apple.ssh.passphrases")
if err != nil {
        log.Fatal(err)
}
fmt.Printf("keyPassword = %s
", keyPassword)

I fund this post, could be related: https://apple.stackexchange.com/a/268175/104123.

Any ideas if this is possible in latest macOs versions?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问