我正在安装杰斯普特并且在尝试运行时ssh -p 4022 jhipster@localhost
,系统要求输入密码。
bash-3.2$ cat ~/.ssh/id_rsa.pub | ssh -p 4022 jhipster@localhost 'mkdir ~/.ssh && cat >> ~/.ssh/authorized_keys'
jhipster@localhost's password:
我应该如何配置/跳过此密码。我已经看过一些帖子,但它们似乎都在讨论 Linux。
日志:
bash-3.2$ ssh -v -p 4022 jhipster@localhost
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 4022.
debug1: Connection established.
debug1: identity file /Users/abhishek/.ssh/id_rsa type 1
debug1: identity file /Users/abhishek/.ssh/id_rsa-cert type -1
debug1: identity file /Users/abhishek/.ssh/id_dsa type -1
debug1: identity file /Users/abhishek/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6p1 Ubuntu-2ubuntu1
debug1: match: OpenSSH_6.6p1 Ubuntu-2ubuntu1 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 98:02:c9:8e:83:f6:fb:3a:20:fd:15:1f:91:63:92:14
debug1: Host '[localhost]:4022' is known and matches the RSA host key.
debug1: Found key in /Users/abhishek/.ssh/known_hosts:4
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/abhishek/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/abhishek/.ssh/id_dsa
debug1: Next authentication method: password
jhipster@localhost's password:
答案1
无密码 ssh 是一个鸡和蛋的问题。直到你设法成功地在中输入~/.ssh/id_rsa.pub
内容,以 身份进行 ssh 时系统会提示您输入密码。您需要输入密码才能使 cmd 成功(假设它是正确的)。jhipster
~/.ssh/authorized_keys
jhipster
对于 cmd 来说同样如此ssh-copy-id
。
由于您已经遇到困难,我建议您尽量让事情变得简单。
- 第一个目标是变得
jhipster@localhost
(否则您无法更新authorized_keys文件)
一种方法是使用 ssh(您需要输入密码):
ssh -p 4022 jhipster@localhost
如果你没有/无法输入密码(比如不知道密码或没有设置密码),但你有根/sudo您可以尝试以下访问:
sudo su - jhipster
或者分别以 root 身份:
su - jhipster
- 登录后,
jhipster
您可以像这样更新您的文件:
mkdir -p ~/.ssh touch ~/.ssh/authorized_keys cat ~abhishek/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
jhipster
注意:最后的命令考虑到了其他用户 ID 已经在中拥有其密钥的可能性,~/.ssh/authorized_keys
这些密钥可能需要保留。