在macOS> = 10.13中检索ssh密码

时间:2018-05-22 16:08:56

标签: macos shell go keychain

这是通过命令行在val usersPerPage = Map("home" -> 23, "contact" -> 12) //Map[String,Int] Document("page_id" -> pageId, "users_per_page" -> Document(usersPerPage)) //Compiles val usersPerTime = Map(180 -> 23, 68 -> 34) //Map[Int,Int] Document("page_id" -> pageId, "users_per_time" -> Document(usersPerTime)) //Doesn't compile val usersConf = Map("age" -> 32, "country" -> "Spain") //Map[String,Any] Document("user_id" -> userId, "user_conf" -> Document(usersConf)) //Doesn't compile 中工作:

macOS < 10.13

或使用此go代码段(使用https://github.com/keybase/go-keychain):

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

在macOS High Sierra中这个已经改变了,不能通过命令行工作也无法让它在尝试这个工作:

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\n", keyPassword)

我为这篇文章提供资金,可能是相关的:https://apple.stackexchange.com/a/268175/104123

在最新的macOs版本中是否可以使用任何想法?

0 个答案:

没有答案