gpt4 book ai didi

linux - SSH 权限被拒绝(公钥)

转载 作者:IT王子 更新时间:2023-10-29 01:21:34 25 4
gpt4 key购买 nike

<分区>

我正在尝试通过 SSH 从 Ubuntu 连接到 Debian。我已经有一个 RSA key ;它与我在 Git 中使用的 key 相同。

我使用以下方法将 key 从 Ubuntu 复制到 Debian:

ssh-copy-id -i ~/.ssh/id_rsa.pub root@ip-address

然后我修改了 Debian 上的 sshd_config 以包括以下内容:

RSAAuthentication yes

PubkeyAuthentication yes

PasswordAuthentication no

然后我重新启动了 SSH 服务。现在我尝试使用 SSH 从 Ubuntu 连接到

ssh -v root@ip-addr

但我得到以下信息:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 10.0.1.64 [10.0.1.64] port 22.
debug1: Connection established.
debug1: identity file /home/koushatalebian/.ssh/id_rsa.pub type 1
debug1: identity file /home/koushatalebian/.ssh/id_rsa.pub-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-8
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.0p1 Debian-4+deb7u2
debug1: match: OpenSSH_6.0p1 Debian-4+deb7u2 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA e2:af:83:f8:df:e2:15:db:77:30:e1:6b:e7:dc:77:99
debug1: Host '10.0.1.64' is known and matches the ECDSA host key.
debug1: Found key in /home/koushatalebian/.ssh/known_hosts:10
debug1: ssh_ecdsa_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
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/koushatalebian/.ssh/id_rsa.pub
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我基本上想强制 SSH 仅通过公钥身份验证发生。

我已经阅读了与该主题相关的所有其他帖子,但没有一篇对我有用。这就是为什么我将其创建为单独的帖子。

编辑

sshd_config 中将 StrictModesyes 更改为 no 解决了这个问题。这样做安全吗?

编辑 2这是服务器上 SSH 的日志:

May  5 18:23:55 lemaker sshd[2591]: Connection from 10.0.1.37 port 42748
May 5 18:23:55 lemaker sshd[2591]: debug1: PAM: setting PAM_RHOST to "10.0.1.37"
May 5 18:23:55 lemaker sshd[2591]: Failed publickey for root from 10.0.1.37 port 42748 ssh2
May 5 18:23:55 lemaker sshd[2591]: Connection closed by 10.0.1.37 [preauth]

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com