如果没有密码,如何在没有密码的情况下ssh到服务器

时间:2015-08-19 14:35:12

标签: ssh passwords public-key

我想设置从本地计算机到此Linux服务器的无密码登录。当我尝试上传我的公钥时,我发现服务器上没有.ssh。所以我在服务器上用ssh-keygen创建了一个。但是在新生成的.ssh目录中,没有authorized_keys或known_hosts。所以我创建了一个新的authorized_keys并从本地机器上粘贴了我的公钥。但是它不起作用,仍然需要ssh的密码。谁能告诉我,我做得对吗?

这是ssh -vvv的输出:

debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive
debug3: start over, passed a different list publickey,gssapi-with-mic,password,keyboard-interactive
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup gssapi-with-mic
debug3: remaining preferred: publickey,keyboard-interactive,password
debug3: authmethod_is_enabled gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug3: Trying to reverse map address .
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_198782' not found

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_198782' not found

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_198782' not found

debug2: we did not send a packet, disable method
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /rsrch2/rists/djiao/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug3: Wrote 368 bytes for a total of 1477
debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /rsrch2/rists/djiao/.ssh/id_dsa
debug3: no such identity: /rsrch2/rists/djiao/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug3: Wrote 96 bytes for a total of 1573
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1

1 个答案:

答案 0 :(得分:1)

只需创建它并将密钥复制到它。如果您有密钥复制工具,则只需通过

创建文件
$ touch ~/.ssh/authorized_keys

使用该工具之前。

使用-vvv连接可能有助于详细说明。

在客户端和服务器上,检查〜/ .ssh是否具有权限700。

在服务器上,检查/etc/ssh/sshd_config是否有:

AuthorizedKeysFile  .ssh/authorized_keys
PubkeyAuthentication yes
RSAAuthentication yes