从ssh-keygen获取默认位置?

时间:2015-01-17 01:54:44

标签: applescript ssh-keygen

如果您没有指定默认目录,则在使用ssh-keygen时会显示默认目录:

Enter file in which to save the key (/Users/username/.ssh/id_rsa): 

我需要获取路径和文件名," /Users/monkeypunch/.ssh/id_rsa"。

1 个答案:

答案 0 :(得分:2)

这个怎么样:

to getDefaultKeyPath()
    try
        do shell script ("ssh-keygen")
    on error response
        set oldDelim to AppleScript's text item delimiters
        set AppleScript's text item delimiters to {"(", ")"}
        set defaultKeyPath to text item 2 of response
        set AppleScript's text item delimiters to oldDelim
    end try
    return defaultKeyPath
end getDefaultKeyPath

getDefaultKeyPath()将返回/Users/monkeypunch/.ssh/id_rsa