SSH-从Mac OSX到CentOS服务器的许可拒绝(publicKey)问题

发布于 2025-02-13 21:49:07 字数 1663 浏览 0 评论 0原文

(有关此问题的大多数线程是AWS或GITHUB相关的。我都不是。这是一个简单的Digital Ocean Centos 8服务器。)

我的旧MacBook无需任何问题即可连接到我的SSH服务器:使用

ssh -2 -p 5555 -i  /Users/Me/.ssh/id_rsa  [email protected]

(端口号和IP更改了隐私,当然。)

我购买了一个新的MacBook Pro,并已经设置了ssh-keygen像往常一样,然后手动将id_rsa.pub手动移动到服务器的.ssh/授权_Keys。在服务器上,我使用nano将其添加到授权密钥文件中,同时登录为root用户。因此,以下是.ssh dir在服务器上以root用户登录时的样子:

990971649 -rw-------. 1 root root 2722 Jul  7 07:52 authorized_keys
990971651 -rw-------. 1 root root 3389 Jan 10  2021 id_rsa
990971652 -rw-------. 1 root root  747 Jan 10  2021 id_rsa.pub

但是,尽管将id_rsa.pub添加到服务器上的授权_keys中,但我会得到此错误:

[email protected]: Permission denied (publickey)

该问题上的大多数线程都通过添加一些参数来“解决”,但是我的ssh_config服务器上的设置似乎还不错...这可以从我的旧MacBook中使用!以下是服务器设置 -

Protocol 2
Port 5555

LoginGraceTime 60
ClientAliveInterval 120
ClientAliveCountMax 3
MaxSessions  6
AllowUsers root 
PermitEmptyPasswords    no
PasswordAuthentication  no
PermitRootLogin         yes
X11Forwarding           no 
MaxAuthTries            6 
IgnoreRhosts            yes
AllowTcpForwarding      no
AllowAgentForwarding    no
Compression             no 
TCPKeepAlive            no 
UseDNS                  no 
HostbasedAuthentication no
PubkeyAuthentication    yes

AuthenticationMethods   publickey

还有什么问题?

(Most threads about this issue are either AWS or GitHub related. Mine is neither. It's a simple Digital Ocean CentOS 8 server.)

My old Macbook connects to my SSH server without any issues:, using

ssh -2 -p 5555 -i  /Users/Me/.ssh/id_rsa  [email protected]

(Port number and IP changed for privacy, of course.)

I bought a new Macbook Pro, and have set up the ssh-keygen stuff as usual, then manually moved the id_rsa.pub to the server's .ssh/authorized_keys. On the server, I did this adding to the authorized keys file using nano while logged in as the root user. So this below is what the .ssh dir looks like on the server, when logged in as the root user:

990971649 -rw-------. 1 root root 2722 Jul  7 07:52 authorized_keys
990971651 -rw-------. 1 root root 3389 Jan 10  2021 id_rsa
990971652 -rw-------. 1 root root  747 Jan 10  2021 id_rsa.pub

But despite adding the id_rsa.pub stuff into the authorized_keys on the server, I get this error:

[email protected]: Permission denied (publickey)

Most threads on this issue have been 'solved' by adding some parameter, but my ssh_config settings on the server seem to be fine...and this works from my old Macbook! Below are the server settings--

Protocol 2
Port 5555

LoginGraceTime 60
ClientAliveInterval 120
ClientAliveCountMax 3
MaxSessions  6
AllowUsers root 
PermitEmptyPasswords    no
PasswordAuthentication  no
PermitRootLogin         yes
X11Forwarding           no 
MaxAuthTries            6 
IgnoreRhosts            yes
AllowTcpForwarding      no
AllowAgentForwarding    no
Compression             no 
TCPKeepAlive            no 
UseDNS                  no 
HostbasedAuthentication no
PubkeyAuthentication    yes

AuthenticationMethods   publickey

What else could be going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

破晓 2025-02-20 21:49:07

要解决使用SHA-1哈希算法默认情况下的OpenSSH 9.0P1禁用RSA签名的问题,您可以按照以下步骤修改SSH_Config文件:

sudo vi /etc/ssh/ssh_config

将以下行添加到SSH_Config的底部:

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa

To address the issue of OpenSSH 9.0p1 disabling RSA signatures using the SHA-1 hash algorithm by default, you can follow these steps to modify the ssh_config file:

sudo vi /etc/ssh/ssh_config

Add the following lines to the bottom of ssh_config:

HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
蓝海 2025-02-20 21:49:07

sshd_config是OpenSSH服务器的配置文件。 SSH_Config是OpenSSH客户端的配置文件。
确保不要将它们混合

您需要编辑服务器配置文件,而不是客户端配置文件( ssh_config

PubkeyAuthentication yes

)您不想使用密钥登录密钥编辑:

但是,如果服务器不在同一位置,则首先尝试使用密钥登录,而不是编辑此键!

PasswordAuthentication  no

并且不要登录作为根安全性!

PermitRootLogin         no

您可以使用 ssh-copy-id 将密钥复制到服务器

ssh-copy-id  -i ~/.ssh/[KEY] -p [PORT] [user]@[IP]

更新:

tosmotity sshd_config中的所有这些行尝试使用允许/现有用户登录,只有使用密码以找出是否还有其他错误:

每次更改SSH服务器文件中的某些内容时,请不要忘记重新启动SSH服务器:

#LoginGraceTime 60
#ClientAliveInterval 120
#ClientAliveCountMax 3
#MaxSessions  6
#AllowUsers root 
#PermitEmptyPasswords    no
PasswordAuthentication  yes
#PermitRootLogin         yes
#X11Forwarding           no 
#MaxAuthTries            6 
#IgnoreRhosts            yes
#AllowTcpForwarding      no
#AllowAgentForwarding    no
#Compression             no 
#TCPKeepAlive            no 
#UseDNS                  no 
#HostbasedAuthentication no
#PubkeyAuthentication    yes
#AuthenticationMethods   publickey

sshd_config is the configuration file for the OpenSSH server. ssh_config is the configuration file for the OpenSSH client.
Make sure not to get them mixed up

You need to edit the server config file not the client config file (ssh_config)

Add or edit this in your sshd_config

PubkeyAuthentication yes

IF you don't wanna login with passwords only keys edit this too:

But first try to login with the key than edit this to no if the server is not on the same location!

PasswordAuthentication  no

And don't login as root security!

PermitRootLogin         no

You can use ssh-copy-id to copy the key to the server

ssh-copy-id  -i ~/.ssh/[KEY] -p [PORT] [user]@[IP]

UPDATE:

Uncomment all this lines in your sshd_config an try to login with a allowed/existing user only with the password to find out if there are other errors:

DON'T FORGET TO RESTART THE SSH SERVER EVERY TIME YOU CHANGE SOMETHING IN THE SSH SERVER FILES:

#LoginGraceTime 60
#ClientAliveInterval 120
#ClientAliveCountMax 3
#MaxSessions  6
#AllowUsers root 
#PermitEmptyPasswords    no
PasswordAuthentication  yes
#PermitRootLogin         yes
#X11Forwarding           no 
#MaxAuthTries            6 
#IgnoreRhosts            yes
#AllowTcpForwarding      no
#AllowAgentForwarding    no
#Compression             no 
#TCPKeepAlive            no 
#UseDNS                  no 
#HostbasedAuthentication no
#PubkeyAuthentication    yes
#AuthenticationMethods   publickey
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文