7 ssh
我生成了一对私有/发布 RSA 密钥。公钥被添加到远程服务器,但是,当我通过 ssh 连接到远程服务器时,通过使用 -v,我可以看到我的本地客户端没有使用 ~/.ssh 中的私钥。如何添加私钥以确保将其用于身份验证?
她是 ssh auth 上的详细输出:
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/nubela/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/nubela/.ssh/identity
debug1: Trying private key: /home/nubela/.ssh/id_dsa
debug1: No more authentication methods to try.
Run Code Online (Sandbox Code Playgroud)
这是我的 ~/.ssh 的 ls -al
[nubela@localhost .ssh]$ pwd
/home/nubela/.ssh
[nubela@localhost .ssh]$ ls -al
total 36
drwx------ 2 nubela guest 4096 2009-11-11 12:28 ./
drwx--x--x 70 nubela guest 4096 2009-11-11 00:53 ../
-rw-r--r-- 1 nubela guest 1486 2009-11-11 12:25 2.ppk
-rw------- 1 nubela guest 604 2009-06-09 04:37 authorized_keys2
-rw------- 1 nubela guest 1743 2009-11-03 23:48 id_rsa
-rw-r--r-- 1 nubela guest 398 2009-11-03 23:48 id_rsa.pub
-rw-r--r-- 1 nubela guest 2803 2009-11-11 13:34 known_hosts
-rw------- 1 nubela guest 1743 2009-11-11 12:21 upperstorey
-rw------- 1 nubela guest 398 2009-11-11 12:21 upperstorey.pub
Run Code Online (Sandbox Code Playgroud)
upperstorey 是我希望使用 ssh 客户端的私钥。我怎样才能添加它?
PS:使用 -i /path/to/privatekey 有效
谢谢!
那么,当连接到 host 时remotehost
,您想使用 upperstorey 中包含的密钥吗?
您需要告诉 ssh 明确使用它。最简单的方法是将以下块添加到您的 ~/.ssh/config 中:
Host remotehost
IdentityFile ~/.ssh/upperstorey
Run Code Online (Sandbox Code Playgroud)
这告诉ssh
在连接到该主机时使用该密钥。将任何别名添加到主机行(即 remotehost、remotehost.remotedomain.com 等)
归档时间: |
|
查看次数: |
15993 次 |
最近记录: |