我使用的是 centOS 5.9。通过此链接安装 GitHubLab 后,SSH 不起作用。在安装 gitlab ssh 正常工作之前。我在本地使用此服务器和其他服务,例如安装在服务器上的Elastix和Apache ,MySQL。
出现此错误:
OpenSSH_6.9p1 Ubuntu-2ubuntu0.1, OpenSSL 1.0.2d 9 Jul 2015
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 192.168.88.23 [192.168.88.23] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9p1 Ubuntu-2ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4* compat 0x00000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 192.168.88.23:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,ssh-dss
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5-etm@openssh.com,hmac-ripemd160-etm@openssh.com,hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,hmac-md5,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<7680<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug2: bits set: 3111/6144
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:7J6JOe94H9PedNKlx6yG/wMy6ZYC8iB74WdOVGDgY7A
debug1: Host '192.168.88.23' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug2: bits set: 3102/6144
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: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /root/.ssh/id_rsa ((nil)),
debug2: key: /root/.ssh/id_dsa ((nil)),
debug2: key: /root/.ssh/id_ecdsa ((nil)),
debug2: key: /root/.ssh/id_ed25519 ((nil)),
debug1: Authentications that can continue: publickey,gssapi-with-mic
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available
debug1: Unspecified GSS failure. Minor code may provide more information
debug1: Unspecified GSS failure. Minor code may provide more information
No Kerberos credentials available
debug2: we did not send a packet, disable method
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/id_rsa
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Trying private key: /root/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-with-mic).
700 设置为 .ssh 和 600 设置为 authorized_keys 解决了这个问题。
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
使用vagrant时遇到了同样的问题。 所以从我的Mac上,我试图ssh到一个流浪的盒子(CentOS 7(
通过修改/etc/ssh/sshd_config
PasswordAuthentication yes
然后使用sudo systemctl restart sshd
重新启动服务来解决
希望这有帮助。
将密码身份验证设置为 yes,并不是最好的方法,不如使用私钥和公钥进行身份验证安全!
首先确保您在服务器端设置了休耕权限。
首先检查您的家庭目录(服务器端(
[vini@random ~]$ ls -ld ~
drwx------. 3 vini vini 127 Nov 23 15:29 /home/vini
如果不是这样,请运行
chmod 0700 /home/your_home
现在检查 .ssh 文件夹
[vini@random ~]$ ls -ld /home/vini/.ssh/
drwx------. 2 vini vini 29 Nov 23 15:28 /home/vini/.ssh/
如果它不是这样,请运行
chmod 0700 /home/your_home/.ssh
现在确保authorized_keys
看起来像这样
[vini@venon ~]$ ls -ld /home/vini/.ssh/authorized_keys
-rw-------. 1 vini vini 393 Nov 23 15:28 /home/vini/.ssh/authorized_keys
或者只是运行
chmod 0600 /home/your_home/.ssh/authorized_keys
之后去/etc/ssh/sshd_config
最佳安全设置
PermitRootLogin no
PubkeyAuthentication yes
保留为yes
以进行测试
PasswordAuthentication yes
确保
ChallengeResponseAuthentication no
为GSSAPI注释这些行
# #GSSAPIAuthentication yes
# #GSSAPICleanupCredentials no
确保设置为 UsePAM yes
UsePAM yes
现在重新启动 SSHD 服务
systemctl restart sshd
在客户端
cd /home/your_home/.ssh
生成新密钥;设置密码是可选的,但是个好主意
ssh-keygen -t rsa -b 2048
将 Pub 密钥复制到服务器
ssh-copy-id -i id_rsa.pub user_name@server_ip
start ssh agent
eval $(ssh-agent)
ssh-add /home/user/.ssh/your_private_key
现在你很好去!
ssh user_name@server_ip
如果一切正常
备份您的私钥,然后拒绝PasswordAuthentication
PasswordAuthentication no
重新启动服务器
现在,任何试图通过ssh进入您的服务器的人,如果没有您的密钥,都应该得到
vini@random: Permission denied (publickey).
让脚本孩子远离您的业务,祝你好运
正如其他人已经说过的那样,您需要编辑/etc/ssh/sshd_config
并将PasswordAuthentication no
更改为PasswordAuthentication yes
我在设置一个 Vagrant box 时遇到了这个问题 - 因此编写脚本并在 shell 配置器中自动执行此操作是有意义的:
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo systemctl restart sshd;
isssue 是 AWS 上 centos 实例上大多数公有密钥错误的用户名。对于拒绝权限(公钥,gssapi-keyex,gssapi-with-mic(:
它非常简单。只需将您的用户名从 centos 更改为 ec2-user,问题就解决了。
以后谢谢我:)
我遇到了同样的问题。就我而言,macOS 不会加载我的 SSH 密钥,但我通过以下方式修复它:
ssh-add <SSH private key>
ssh-add <SSH public key>
我无法连接到DigitalOcean上的Droplet,但随后的命令对我有用。
您可以在此处访问论坛。
请确保以下更改应该取消注释,我做到了并在 centos7 中取得了成功
vi /etc/ssh/sshd_config
1.PubkeyAuthentication yes
2.PasswordAuthentication yes
3.GSSAPIKeyExchange no
4.GSSAPICleanupCredentials no
systemctl restart sshd
ssh-keygen
chmod 777 /root/.ssh/id_rsa.pub
ssh-copy-id -i /root/.ssh/id_rsa.pub user@ipaddress
谢谢大家,祝你好运
根据第 debug1: Authentications that can continue: publickey,gssapi-with-mic
行,ssh 密码身份验证被禁用,显然您没有使用公钥身份验证。
使用控制台登录到您的服务器,并使用带有 root 用户的编辑器打开/etc/ssh/sshd_config
文件并查找第 PasswordAuthentication
行,然后将其值设置为 yes,最后重新启动 sshd 服务。
尝试了很多事情,但没有帮助。
它以简单的方式获得访问权限:
eval $(ssh-agent) > /dev/null
killall ssh-agent
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
请注意,ssh-add -L
输出的末尾一定不是密钥的路径,而是您的电子邮件。
In Centos 7
错误:公钥,gssapi-keyex,gssapi-with-mic
答:对 vi/etc/ssh/sshd_config 的根访问权限,并将密码身份验证 ( no ( 更改为 yes。
阿拉伯数字。重新启动 sshd 服务
root> systemctl restart sshd.service
- 无需密钥即可通过腻子登录本地 ID。
这是一个老问题,但我想我会在锅中添加我的修复程序。
我在尝试从 Ubuntu 连接到 Amazon Linux 时遇到同样的错误。解决方案是简单地更改它:
ssh-add -c <key_location>.pem
对此:
ssh-add "<key_location>.pem"
。很简单的改变让我进去了。
正如其他一些人所提到的,当您通过ssh进入服务器时,请确保您使用了正确的私钥。我的目录中设置了多个 ssh 私钥,因此它默认为不同的密钥。要使用正确的键在 CLI 调用ssh centos@IP-ADDRESS -i YOUR-PATH-TO-KEY
中调用它进行 ssh ,在我的情况下,路径~/.ssh/id_rsa
没有人提到这一点。 以上答案,所以我提到它。
如果您在错误的文件夹中或 pem 文件的路径不正确,也可能会出现此错误。我遇到了类似的问题,发现我的 pem 文件不存在我正在执行 ssh 命令的地方
cd KeyPair
ssh -i Keypair.pem ec2-user@244.255.255.255
通过在/etc/ssh/sshd_config 中将 GSSAPIAuthentication 设置为 no 来修复
您应该将公钥分配给authorized_keys
,执行此操作的简单方法是使用 ssh-copy-id -i your-pub-key-file user@dest
。
这将清除发布问题的原因,实际上这是pssh本身的错误(包含在"askpass-client.py"中(。它是 pssh 的库文件。并且有记录在案的 -A 案例问题:https://code.google.com/archive/p/parallel-ssh/issues/80有两种可能的解决方案可以使用包含此错误的 pssh 版本,以防您被迫使用密码进行私钥访问:
- 更正您的"askpass-client.py",如我帖子之前列出的链接中所述。
- 使用您最喜欢的通行证守门员。
感谢您的关注,希望对您有所帮助!
我试试
rm ~/.ssh/id_rsa.pub
然后它起作用了!
首先,必须为远程计算机建立密码登录
- 首先进行密码登录
您必须通过启用属性来启用密码登录,即(密码身份验证是sshd_config文件中的。然后重新启动 sshd 服务并将 pub 密钥复制到远程服务器(在我的情况下为 aws ec2(,密钥将被复制而没有任何错误
- 没有密码登录当且仅当首先进行密码登录时有效
- 将 PUB 密钥内容复制到授权密钥,cat xxx.pub>> ~/.ssh/authorized_keys
缺少在 authorized_keys 中为 AWS 实例设置的正确id_rsa密钥,则可能会发生这种情况。
我得到的确切错误(当我用谷歌搜索错误时,这篇文章出现了(:
ec2-user@X.X.X.X: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
注意:如果有许多密钥,则必须在 ssh 命令行上指定密钥,或者将其添加到 ssh 代理密钥中(请参阅 ssh-add -l(。只有来自 ssh-agent 的前 6 个密钥可以工作 - 默认的 sshd MaxAuthTry 配置值为 6。
希望,这将帮助某人。我遇到的问题是,我完全使用了错误的IP密钥。确保您为正确的 IP
这是一个完全错误的,有人将密钥与另一个密钥复制粘贴到同一行中,将它们分成两行后,然后它再次工作,所以请检查您的authorized_key文件是否有类似的错误!
我之前遇到了同样的问题权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic(。
我不得不去/etc/ssh/sshd_config 将用户用户添加到 AllowUsers 部分,然后重新启动 sshd 服务。
让我与您分享我是如何做到的,我相信您会在这里找到很好的答案。
确保满足以下条件
第 1 步。你有
Public DNS (IPv4) from aws
例如 ec2-IPV4.us-east-2.compute.amazonaws.com
第 2 步。您记得您的
your_secret_key_is.pem
在哪里,例如最好将其远离已知文件夹(如下载,桌面或文档(的根目录
步骤3 打开终端并添加命令
sudo ssh -v -i path-to-key.pem ec2-user@host
EC2-user很重要,因为它对于某些Linux服务器来说是用户名
sudo 它需要执行权限
主机是 Amazon Public DNS (IPv4((复制步骤 1(
在此处查找更多信息
Permission denied (publickey)
在我的情况下,似乎是由SSH客户端而不是SSH服务器生成的问题。以下是导致我的问题的原因以及我如何解决。问题来源是我使用sudo
生成如下密钥:
sudo ssh-keygen -t ed25519 -f ~/.ssh/serverA_ed25519_key
这会自动将这些密钥文件的所有者设置为仅 root,因此我的当前用户无权读取密钥。
现在的解决方案#1是将文件所有权更改为当前用户。这就是我所做的。
sudo chown CURRENT_USER ~/.ssh/serverA_ed25519_key
解决方案#2只是在尝试连接到ssh服务器时运行带有sudo
的ssh客户端。
最后,一个找出ssh客户端问题根源的技巧。
ssh -v -o IdentitiesOnly=yes -i ~/.ssh/serverA_ed25519_key me@serverA
这让我通过以下方式专注于问题:
- 按
-v
标志显示详细信息。 -o
选项和-i ~/.ssh/serverA_ed25519_key
强制 SSH 客户端仅使用此密钥尝试,而不是您拥有的所有密钥。
我也有这个错误信息:Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
使用 cmd:ssh -i "~/.ssh/old.pem" user@ip
导致错误。
问题是old.pem
已弃用,更改为最新的 pem 文件后,错误消失。
就我而言,我使用了错误的用户名。修复了这个问题,问题得到了解决。
问题很简单,密钥的所有者应该是一个,以防万一 linux/Mac 的窗口(只是删除其他用户并只保留一个或拒绝其他用户的权限(只是做一个 chmod 400,因为这只会向用户授予读取权限,而没有对组或公共的权限。
我在从 Mac(主机(连接到 CentOS(7.9( 客户机时遇到了这个奇怪的错误。在连接成功之前,我必须将密钥文件显式传递给ssh
客户端ssh root@ip -i private_key_file
。
早些时候,我在通常的密钥生成后启用了以下内容,并使用ssh-keygen
和复制ssh-copy-id
PermitRootLogin 是的,#Logging in with root,它是默认设置的
密码身份验证编号
我决定不使用ssh-keygen
提供的默认名称,尽管生成的文件保存在与默认值相同的位置。
我保留了其他默认值不变。不要忘记在远程计算机上重新启动 sshd。
我成功了!!我从另一台计算机复制了ssh_keys并尝试登录到我的 AWS EC2,但失败了:
sign_and_send_pubkey:代理对 RSA"/home/xxxx/.ssh/my_rsa"的签名失败:代理拒绝操作ec2-user@bla-blah-blah.zzzzz.amazonaws.com:权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic(。
解决方案是:
CD $HOME/.ssh
ls -l
-r-x------ 1 xxxx xxxx 1766 五月 4 09:13 id_rsa
-r-x------ 1 xxxx xxxx 405 五月 4 09:13 id_rsa.pub
-rw-r--r-- 1 xxxx xxxx 444 五月 6 17:18 known_hosts
可选命令:马币known_hosts
CHMOD 400 ID*
ssh -i ./id_rsa.pub ec2-user@bla-blah-blah.zzzzz.amazonaws.com
上次登入时间: 2022 年 5 月 6 日星期五 19:09:48 来自 123.456.77.9
__| __|_ )
_| ( / Amazon Linux 2 AMI
___|___|___|
只需运行此命令即可将您的密钥添加到当前用户的本地主机。
ssh-copy-id localhost