使用公钥通过SSH连接到服务器

Dis*_*ant 5 iphone ssh public-key

我正在开发一个我们需要使用SSH集成的iPhone应用程序.我有可以使用密码连接服务器的演示,但我无法获得如何使用公钥连接它.

我可以使用以下命令通过MAC终端连接它.

ssh -i(KeyFilePath)username @(域名或IP)

但遗憾的是,我无法使用Xcode进行连接.

谢谢,

小智 2

您可能需要考虑首先将私钥(或多个密钥)添加到身份验证代理。从那时起,所有 ssh 命令都将重新使用缓存的密钥:

# Add a new key to the authentication agent
$ ssh-add <path to private key>

# List current keys
$ ssh-add -l

# Delete all loaded keys
$ ssh-add -D

# Add a new key and store the passphrase in your keychain
$ ssh-add -K <path to private key1>
$ ssh-add -K <path to private key2>

# After storing the private keys passphrase in the keychain,
# you can load them all, at any time
$ ssh-add -k
Run Code Online (Sandbox Code Playgroud)

当身份验证代理加载私钥时,您应该能够使用 Xcode 毫无问题地连接到(域名或 IP)。