AuthorizedPrincipalsFile 无

AuthorizedPrincipalsFile 无

我被禁止使用我的 root 和我的用户名连接到 linode。我已阅读了所有其他帖子,但没有任何解决方案对我有用。当我之前连接到 ssh 时,出于安全原因,我阻止了 root 登录,并创建了一个使用 ssh 密钥登录且不允许密码登录的用户。一段时间内它运行良好,但现在当我尝试连接到 root 或我的用户时,出现了权限被拒绝的情况。

答案1

我也遇到了同样的问题。我阅读了通过搜索上述主题中的字符串找到的数十条帖子,但都无济于事。

我遗漏了一些东西 - 可能是基本的 - 并且需要另一双/多双眼睛才能看清那是什么。

所以我做了以下事情。我将开发桌面从 Ubuntu 19.10 升级到了 20.04,但明智的是,我还没有将“生产”桌面从 18.04 升级,而且在我所有的应用程序都正常运行之前,我不会这样做。

ssh 在 20.04“客户端”上似乎没问题,直到我开始调整它以让 Mysql Workbench 连接到服务器。

我现在不断收到主题中的错误消息。

以下是命令 ssh -i -vvv server_ip 的输出

`OpenSSH_7.6p1 Ubuntu-4ubuntu0.3,OpenSSL 1.0.2n 2017 年 12 月 7 日 debug1:读取配置数据 /etc/ssh/ssh_config debug1:/etc/ssh/ssh_config 第 19 行:应用 * 的选项 debug2:解析“192.168.1.10”端口 22 debug2:ssh_connect_direct:needpriv 0 debug1:连接到 192.168.1.10 [192.168.1.10] 端口 22。 debug1:建立连接。 debug1:permanently_set_uid:0/0 debug1:身份文件/root/.ssh/id_rsa.pub 类型 0 debug1:key_load_public:没有此文件或目录 debug1:身份文件/root/.ssh/id_rsa.pub-cert 类型 -1 debug1:身份文件/root/.ssh/id_rsa 类型 0 debug1:key_load_public:没有此文件或目录 debug1:身份文件/root/.ssh/id_rsa-cert 类型 -1 debug1:本地版本字符串 SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 debug1:远程协议版本 2.0,远程软件版本 OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 debug1:match:OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000 debug2:fd 3 设置 O_NONBLOCK debug1:以 'root' 身份向 192.168.1.10:22 进行身份验证 debug3: hostkeys_foreach: 读取文件 "/root/.ssh/known_hosts" debug3: record_hostkey: 在文件 /root/.ssh/known_hosts:2 中发现密钥类型 ECDSA debug3: load_hostkeys: 从 192.168.1.10 加载了 1 个密钥 debug3: order_hostkeyalgs: 首选 hostkeyalgs:[电子邮件保护][电子邮件保护][电子邮件保护],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521 debug3:发送数据包:类型 20 debug1:SSH2_MSG_KEXINIT 已发送 debug3:接收数据包:类型 20 debug1:SSH2_MSG_KEXINIT 已接收 debug2:本地客户端 KEXINIT 提议 debug2:KEX 算法:curve25519-sha256,[电子邮件保护],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c debug2:主机密钥算法:[电子邮件保护][电子邮件保护][电子邮件保护],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[电子邮件保护][电子邮件保护],ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa debug2: 密码 ctos:[电子邮件保护],aes128-ctr,aes192-ctr,aes256-ctr,[电子邮件保护][电子邮件保护] debug2:密码存储:[电子邮件保护],aes128-ctr,aes192-ctr,aes256-ctr,[电子邮件保护][电子邮件保护] 调试2:MACs ctos:[电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MAC 库存:[电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: 压缩 ctos: 无,[电子邮件保护],zlib debug2: 压缩库: 无,[电子邮件保护],zlib debug2:语言 ctos:debug2:语言 stoc:debug2:first_kex_follows 0 debug2:保留 0 debug2:对等服务器 KEXINIT 提案 debug2:KEX 算法:curve25519-sha256,[电子邮件保护],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1 debug2:主机密钥算法:ssh-rsa、rsa-sha2-512、rsa-sha2-256、ecdsa-sha2-nistp256、ssh-ed25519 debug2:密码 ctos:[电子邮件保护],aes128-ctr,aes192-ctr,aes256-ctr,[电子邮件保护][电子邮件保护] debug2:密码存储:[电子邮件保护],aes128-ctr,aes192-ctr,aes256-ctr,[电子邮件保护][电子邮件保护] 调试2:MACs ctos:[电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: MAC 库存:[电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护][电子邮件保护],hmac-sha2-256,hmac-sha2-512,hmac-sha1 debug2: 压缩 ctos: 无,[电子邮件保护] debug2:压缩库存:无,[电子邮件保护] debug2:语言 ctos:debug2:语言 stoc:debug2:first_kex_follows 0 debug2:保留 0 debug1:kex:算法:curve25519-sha256 debug1:kex:主机密钥算法:ecdsa-sha2-nistp256 debug1:kex:服务器->客户端密码:[电子邮件保护]MAC:压缩:无 debug1:kex:客户端->服务器密码:[电子邮件保护]MAC:压缩:无 debug3:发送数据包:类型 30 debug1:期待 SSH2_MSG_KEX_ECDH_REPLY debug3:接收数据包:类型 31 debug1:服务器主机密钥:ecdsa-sha2-nistp256 SHA256:ihT4T/0uZlh6ujuMQIWNoKWdf8zONBap92BeMbstNtg debug3:hostkeys_foreach:读取文件“/root/.ssh/known_hosts” debug3:record_hostkey:在文件 /root/.ssh/known_hosts:2 中找到密钥类型 ECDSA debug3:load_hostkeys:从 192.168.1.10 加载 1 个密钥 debug1:主机“192.168.1.10”已知且与 ECDSA 主机密钥匹配。 debug1:在 /root/.ssh/known_hosts:2 中找到密钥 debug3:发送数据包:类型 21 debug2:set_newkeys:模式 1 debug1:在 134217728 个块后重新加密 debug1:SSH2_MSG_NEWKEYS 已发送 debug1:期待 SSH2_MSG_NEWKEYS debug3:接收数据包:类型 21 debug1:SSH2_MSG_NEWKEYS 已接收 debug2:set_newkeys:模式 0 debug1:在 134217728 个块后重新加密 debug2:密钥:/root/.ssh/id_rsa.pub(0x55ee3b0d8ad0),显式 debug2:密钥:/root/.ssh/id_rsa(0x55ee3b0d7d30) debug3:发送数据包:类型 5 debug3:接收数据包:类型 7 debug1:SSH2_MSG_EXT_INFO 已接收 debug1: kex_input_ext_info:server-sig-algs = debug3:接收数据包:类型 6 debug2:service_accept:ssh-userauth debug1:SSH2_MSG_SERVICE_ACCEPT 已接收 debug3:发送数据包:类型 50 debug3:接收数据包:类型 53 debug3:input_userauth_banner Ubuntu 18.04.4 LTS \n \l

debug3:接收数据包:类型 51 debug1:可以继续的身份验证:publickey debug3:重新开始,传递了不同的列表publickey debug3:首选 gssapi-keyex、gssapi-with-mic、publickey、keyboard-interactive debug3:authmethod_lookup publickey debug3:剩余首选:keyboard-interactive debug3:authmethod_is_enabled publickey debug1:下一个身份验证方法:publickey debug1:提供公钥:RSA SHA256:sOPLHvZ4E2sxXV2Cvs2/HqGH5Rkx/Wx2KdSsNULofl8 /root/.ssh/id_rsa.pub debug3:send_pubkey_test debug3:发送数据包:类型 50 debug2:我们发送了一个公钥数据包,等待回复 debug3:接收数据包:类型 51 debug1:可以继续的身份验证:publickey debug1:提供公钥:RSA SHA256:sOPLHvZ4E2sxXV2Cvs2/HqGH5Rkx/Wx2KdSsNULofl8 /root/.ssh/id_rsa debug3:send_pubkey_test debug3:发送数据包:类型 50 debug2:我们发送了一个公钥数据包,等待回复 debug3:接收数据包:类型 51 debug1:可以继续的身份验证:公钥 debug2:我们没有发送数据包,禁用方法 debug1:没有更多身份验证方法可尝试。 [电子邮件保护]:权限被拒绝(公钥)。`

它从哪里获取公钥 SHA256:sOPLHvZ4E...?我在任何 id_rsa* 文件中都找不到这样的字符串,在服务器上的 authorized_keys 中也找不到。

这是我所做的:1. apt-get remove ssh 2. apt-get purge ssh 在客户端上,然后重新安装 3. apt-get install openssh-client

在服务器上 apt-get remove ssh apt-get remove openssh-server apt-get purge ssh apt-get purge openssh-server

我在服务器和客户端上的权限都是 /root/.ssh 目录为 700,id_rsa.pub 为 644,id_rsa 为 600

我在客户端上运行了 ssh-keygen,并将 id_rsa.pub 的内容复制到服务器上的 authorized_keys。在两台机器的 /etc/ssh/ssh_config 中,我 PasswordAuthentication no IdentityFile ~/.ssh/id_rsa 在客户端的 /etc/ssh/sshd_config 中也有, PubkeyAuthentication yes RSAAuthentication yes PasswordAuthentication no 但我还注释掉了以下几行(这样可以吗?)`#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2

AuthorizedPrincipalsFile 无

AuthorizedKeysCommand 无

AuthorizedKeysCommandUser 没人`

X11Forwarding no MaxStartups 2:30:10 AllowUsers <me> root

在服务器上:在 ssh_config 中: PasswordAuthentication no IdentityFile ~/.ssh/id_rsa ------> should this be authorized_keys??? 在 sshd_config 中:`LogLevel VERBOSE LoginGraceTime 30 PermitRootLogin yes RSAAuthentication yes

授权密钥文件 .ssh/authorized_keys .ssh/authorized_keys2

PasswordAuthentication 没有 AllowTcpForwarding 没有 MaxStartups 2:30:10`

/var/log/auth.log 中没有什么特别引起我注意的东西。

那么,你能发现错误的原因吗?

提前致谢。

2020 年 5 月 5 日

我通过在本地客户端上安装 openssh-server 解决了这个问题 - 非常简单!!!!

答案2

也许你的 ssh 代理已停止,请尝试以下操作:

eval $(ssh-agent)
ssh-add /path/to/your/key

No more authentication methods to try. [email protected]: Permission denied (publickey).

似乎ssh-agent没有正确的 ssh 密钥来验证连接。

相关内容