有或没有 rsa 密钥,ssh 连接都会失败

有或没有 rsa 密钥,ssh 连接都会失败

我在办公室有一台运行 Ubuntu 的机器。我在家里有一台运行 Mint 的机器。我的目标是能够在家使用 ssh 连接到办公室进行工作。

我发誓我尝试在论坛中寻找类似的错误,但它们对我来说都是不同的,或者解决方案对我来说很奇怪。请耐心等待。

我做了什么:

我把我的家用笔记本电脑带到工作的地方,以便对其进行正确的配置。

从两台机器上清除 ssh

再次安装它们

尝试从客户端(个人笔记本电脑)通过 ssh 连接到服务器(工作机器),但失败了。它似乎无法识别我的密码。

stefania@host's password: 
Permission denied, please try again.
stefania@host's password: 
Permission denied, please try again.
stefania@host's password: 
Permission denied (publickey,password)

然后尝试使用 RSA 密钥进行身份验证来避免该问题

ssh-keygen -t rsa on the client

没有密码

ssh-copy-id 无法工作(当然,存在同样的密码问题),因此我使用 pendrive 传输客户端 id_rsa.pub,并在服务器端手动生成了 authorized_keys 文件,并确保两个 ~/.ssh 文件夹的 chmod 为 600 和 chmod 700。

所有配置文件(/etc/ssh/ssh_config 和 /etc/ssh/sshd_config)均未改动,因此设置为默认值并启用 rsakey 身份验证。(为了确保没有错误,我将这两个文件与朋友编写的、实际上可以进行 ssh 连接的文件进行了比较,发现它们是相同的)

重审

ssh -vvv name@host 

(我只会发布有趣的部分)

OpenSSH_6.2p2 Ubuntu-6ubuntu0.4, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to hostip [hostip] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/clientuser/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /home/clientuser/.ssh/id_rsa type 1

debug1: Server host key: RSA 78:0e:41:cd:69:50:e5:25:b3:98:0d:c1:cb:37:69:c6
debug3: load_hostkeys: loading entries for host "hostip" from file "/home/clientuser/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/clientuser/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'hostip' is known and matches the RSA host key.
debug1: Found key in /home/clientuser/.ssh/known_hosts:1
debug2: bits set: 557/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/clientuser/.ssh/id_rsa (0x7f8c00e1c690),
debug2: key: /home/clientuser/.ssh/id_dsa ((nil)),
debug2: key: /home/clientuser/.ssh/id_ecdsa ((nil)),
debug3: input_userauth_banner
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/clientuser/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/clientuser/.ssh/id_dsa
debug3: no such identity: /home/clientuser/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/clientuser/.ssh/id_ecdsa
debug3: no such identity: /home/clientuser/.ssh/id_ecdsa: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
serveruser@hostip's password: 

服务器端无法找到密钥并提示输入密码,但这并不像上面提到的那样起作用。

我迷路了。非常感谢

答案1

我不是这方面的专家,

但在我的建议中,请尝试使用本教程:

https://help.ubuntu.com/community/SSH/OpenSSH/Keys

相关内容