ali*_*adi 16 ssh centos gitlab
我用的是centos 5.9.通过此链接安装gitlab后ssh无法正常工作.在安装gitlab ssh之前正确工作.我正在使用这个服务器localy和其他服务,如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).
Run Code Online (Sandbox Code Playgroud)
小智 26
使用vagrant时我遇到了同样的问题.所以从我的Mac我试图ssh到一个流浪盒(CentOS 7)
通过修改/ etc/ssh/sshd_config'PasswordAuthentication yes'来解决它,然后重新启动服务'sudo systemctl restart sshd'
希望这可以帮助.
Dur*_*oka 19
该问题是 AWS 上 centos 实例上大多数公钥错误的用户名。对于权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic):
这很简单。只需将您的用户名从 centos 更改为 ec2-user 即可解决问题。
晚点再谢我 :)
小智 12
将700设置为.ssh并将600设置为authorized_keys可解决此问题。
chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)
小智 11
将 PasswordAuthentication 设置为 yes,不是最好的方法,不如使用私钥和公钥进行身份验证安全!
首先确保您在服务器端设置了空闲权限。
首先检查您的主目录(服务器端)
[vini@random ~]$ ls -ld ~
drwx------. 3 vini vini 127 Nov 23 15:29 /home/vini
Run Code Online (Sandbox Code Playgroud)
如果不是这样,运行
chmod 0700 /home/your_home
Run Code Online (Sandbox Code Playgroud)
现在检查 .ssh 文件夹
[vini@random ~]$ ls -ld /home/vini/.ssh/
drwx------. 2 vini vini 29 Nov 23 15:28 /home/vini/.ssh/
Run Code Online (Sandbox Code Playgroud)
如果它看起来不像这样,请运行
chmod 0700 /home/your_home/.ssh
Run Code Online (Sandbox Code Playgroud)
现在确保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
Run Code Online (Sandbox Code Playgroud)
或者就跑
chmod 0600 /home/your_home/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)
之后去 /etc/ssh/sshd_config
最佳安全设置
PermitRootLogin no
PubkeyAuthentication yes
Run Code Online (Sandbox Code Playgroud)
保留作为yes
测试目的
PasswordAuthentication yes
Run Code Online (Sandbox Code Playgroud)
确保
ChallengeResponseAuthentication no
Run Code Online (Sandbox Code Playgroud)
为 GSSAPI 注释这些行
# #GSSAPIAuthentication yes
# #GSSAPICleanupCredentials no
Run Code Online (Sandbox Code Playgroud)
确保设置为 UsePAM yes
UsePAM yes
Run Code Online (Sandbox Code Playgroud)
现在重启 sshd 服务
systemctl restart sshd
Run Code Online (Sandbox Code Playgroud)
在客户端
cd /home/your_home/.ssh
Run Code Online (Sandbox Code Playgroud)
生成新密钥;设置密码是可选的,但这是一个好主意
ssh-keygen -t rsa -b 2048
Run Code Online (Sandbox Code Playgroud)
将公钥复制到您的服务器
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
Run Code Online (Sandbox Code Playgroud)
现在你可以走了!
ssh user_name@server_ip
Run Code Online (Sandbox Code Playgroud)
如果一切正常
备份您的私钥,然后拒绝 PasswordAuthentication
PasswordAuthentication no
Run Code Online (Sandbox Code Playgroud)
重启你的服务器
现在任何试图通过 ssh 进入您的服务器而没有您的密钥的人都应该得到
vini@random: Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
让脚本小子远离你的生意,祝你好运
Joh*_*ohn 10
至于其他人已经表示需要编辑/etc/ssh/sshd_config
和更改PasswordAuthentication no
到PasswordAuthentication yes
我遇到了设置Vagrant框的问题 - 所以编写脚本并在shell配置器中自动执行它是有意义的:
sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo systemctl restart sshd;
我有同样的问题。就我而言,macOS 不会加载我的 SSH 密钥,但我可以使用以下方法修复它:
ssh-add <SSH private key>
ssh-add <SSH public key>
Run Code Online (Sandbox Code Playgroud)
我无法连接到 DigitalOcean 上的 Droplet,但后续命令对我有用。
你可以去这里的论坛。
小智 7
请确保以下更改应取消注释,我这样做并在 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
Run Code Online (Sandbox Code Playgroud)
谢谢大家,祝你好运
根据该行debug1: Authentications that can continue: publickey,gssapi-with-mic
,ssh 密码身份验证已禁用,显然您没有使用公钥身份验证。
使用控制台登录到您的服务器,并/etc/ssh/sshd_config
使用 root 用户的编辑器打开文件,查找行PasswordAuthentication
,然后将其值设置为 yes,最后重新启动 sshd 服务。
尝试了很多东西,都没有帮助。
它以简单的方式访问:
eval $(ssh-agent) > /dev/null
killall ssh-agent
eval `ssh-agent`
ssh-add ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
请注意,输出的末尾ssh-add -L
不能是密钥的路径,而是您的电子邮件。
归档时间: |
|
查看次数: |
75365 次 |
最近记录: |