我怎样才能使 SSH 工作?

我怎样才能使 SSH 工作?

我的电脑正在运行 Lubuntu 20.04。

我正在尝试 ssh 到运行 Ubuntu Server 22.04 的 raspberry pi 4。

我已按照安装说明进行操作,但看到以下内容:

ssh -v [email protected]
OpenSSH_8.2p1 Ubuntu-4ubuntu0.11, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/paul/.ssh/config
debug1: /home/paul/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 192.168.1.121 [192.168.1.121] port 22.
debug1: Connection established.
debug1: identity file /home/paul/.ssh/id_rsa type 0
debug1: identity file /home/paul/.ssh/id_rsa-cert type -1
debug1: identity file /home/paul/.ssh/id_dsa type -1
debug1: identity file /home/paul/.ssh/id_dsa-cert type -1
debug1: identity file /home/paul/.ssh/id_ecdsa type -1
debug1: identity file /home/paul/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/paul/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/paul/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/paul/.ssh/id_ed25519 type -1
debug1: identity file /home/paul/.ssh/id_ed25519-cert type -1
debug1: identity file /home/paul/.ssh/id_ed25519_sk type -1
debug1: identity file /home/paul/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/paul/.ssh/id_xmss type -1
debug1: identity file /home/paul/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.11
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.9p1 Ubuntu-3ubuntu0.6
debug1: match: OpenSSH_8.9p1 Ubuntu-3ubuntu0.6 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.1.121:22 as 'paul'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:hB5vu/iLN16xccrKvXJVhJcCL09bFePcmv/GwEwNEL0
debug1: Host '192.168.1.121' is known and matches the ECDSA host key.
debug1: Found key in /home/paul/.ssh/known_hosts:9
debug1: resetting send seqnr 3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: resetting read seqnr 3
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/paul/.ssh/id_rsa RSA SHA256:o4u2FI6udyWLZqKgV2itDrRJaTQYn65ochhOFkPYfd4
debug1: Will attempt key: /home/paul/.ssh/id_dsa 
debug1: Will attempt key: /home/paul/.ssh/id_ecdsa 
debug1: Will attempt key: /home/paul/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /home/paul/.ssh/id_ed25519 
debug1: Will attempt key: /home/paul/.ssh/id_ed25519_sk 
debug1: Will attempt key: /home/paul/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected]>
debug1: kex_input_ext_info: [email protected] (unrecognised)
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/paul/.ssh/id_rsa RSA SHA256:o4u2FI6udyWLZqKgV2itDrRJaTQYn65ochhOFkPYfd4
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/paul/.ssh/id_dsa
debug1: Trying private key: /home/paul/.ssh/id_ecdsa
debug1: Trying private key: /home/paul/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/paul/.ssh/id_ed25519
debug1: Trying private key: /home/paul/.ssh/id_ed25519_sk
debug1: Trying private key: /home/paul/.ssh/id_xmss
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

我按照各种帖子的建议向我的 ~/.ssh/config 添加了一些选项(但无济于事)。它们是:

Host *
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa

我每年都会用这个东西一次,当我买了一个新的 Pi 时(每年都会详细记录我做了什么),但每年它都会以不同的方式失败。任何解决方案都非常受欢迎。

答案1

[email protected]: Permission denied (publickey).

您应该将服务器(在您的情况下为 Raspberry Pi)上的公共 ssh 密钥添加到authorized_keys用户主目录中的文件中 ( /home/paul/.ssh/authorized_keys)。

相关内容