裸机部署报错,ssh互信的前提下

【TiDB 使用环境】生产
【TiDB 版本】v8.5.1
【Linux系统版本】Rocky Linux 9.4
前提:
已配置ssh互信,通过ssh命令连接其他服务器无需输入密码就能连接到。sudo -u root命令能切换到root用户。用admin用户安装的


image

执行check命令时报如下错误
tiup cluster check ./topology-zz.yaml --user admin -p
而且报错的host是当前所在的服务器IP

2025-04-07T18:21:00.884+0800    ERROR   SSHCommand      {"host": "10.0.***.**", "port": "22", "cmd": "export LANG=C; PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin; /usr/bin/sudo -H bash -c \"uname -m\"", "error": "ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain", "stdout": "", "stderr": ""}
2025-04-07T18:21:00.884+0800    ERROR   CheckPoint      {"host": "10.0.***.**", "port": 22, "user": "admin", "sudo": false, "cmd": "uname -m", "stdout": "", "stderr": "", "error": "executor.ssh.execute_failed: Failed to execute command over SSH for 'admin@10.0.***.**:22' {ssh_stderr: , ssh_stdout: , ssh_command: export LANG=C; PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin; /usr/bin/sudo -H bash -c \"uname -m\"}, 
cause: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain", "errorVerbose": "executor.ssh.execute_failed: Failed to execute command over SSH for 'admin@10.0.***.**:22' {ssh_stderr: , ssh_stdout: , ssh_command: export LANG=C; PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin; /usr/bin/sudo -H bash -c \"uname -m\"}, 
cause: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain\n 
at github.com/pingcap/tiup/pkg/cluster/executor.(*EasySSHExecutor).Execute()\n\t
github.com/pingcap/tiup/pkg/cluster/executor/ssh.go:174\n 
at github.com/pingcap/tiup/pkg/cluster/executor.(*CheckPointExecutor).Execute()\n\t
github.com/pingcap/tiup/pkg/cluster/executor/checkpoint.go:86\n 
at github.com/pingcap/tiup/pkg/cluster/task.(*Shell).Execute()\n\t
github.com/pingcap/tiup/pkg/cluster/task/shell.go:43\n 
at github.com/pingcap/tiup/pkg/cluster/task.(*Serial).Execute()\n\t
github.com/pingcap/tiup/pkg/cluster/task/task.go:86\n 
at github.com/pingcap/tiup/pkg/cluster/task.(*StepDisplay).Execute()\n\t
github.com/pingcap/tiup/pkg/cluster/task/step.go:111\n 
at github.com/pingcap/tiup/pkg/cluster/task.(*Parallel).Execute.func1()\n\t
github.com/pingcap/tiup/pkg/cluster/task/task.go:144\n 
at runtime.goexit()\n\truntime/asm_amd64.s:1650", "__hash__": "775384c48a95f7047c016cbf2905eec1e267f629", "__func__": "github.com/pingcap/tiup/pkg/cluster/executor.(*CheckPointExecutor).Execute", "hit": false}

下面是我手动执行的结果
image

没手动输入密码吧,试下密码写到命令行里面看看

配置了互信,不用密码很快就报错。若在执行命令的时候使用-p,输入密码,等待一会儿之后还会报这个错误

ssh下本机看下

admin能无密码sudo么?如果不能,那部署就会失败

配置本机免密了吗

本机免密也设置了,ssh 本机IP,无需输入密码就能login

ssh 本机无需输入密码就能连接

可以的, sudo 没问题

HELP,哪位大佬帮忙看看,有什么解决方案没? :pray:

不手工配置互相,只配置本机sudo权限,让tiup自己配置互信,看行不行。。。

sudo 已经配置过了。最开始的时候就是让tiup自己互信不行,才自己手动配置的互信 :sneezing_face:

cat /etc/ssh/sshd_config 看下呢

[admin@ps-******-app01 tidb]$ sudo cat /etc/ssh/sshd_config
#       $OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# To modify the system-wide sshd configuration, create a  *.conf  file under
#  /etc/ssh/sshd_config.d/  which will be automatically included below
Include /etc/ssh/sshd_config.d/*.conf

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes
ChallengeResponseAuthentication no


# Change to no to disable s/key passwords
#KbdInteractiveAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in RHEL and may cause several
# problems.
#UsePAM no
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server
PermitRootLogin yes

试一下调整ssh 连接数
https://docs.pingcap.com/zh/tidb/stable/tiup-faq/#集群部署期间tiup-收到报错-ssh-handshake-failed-read-tcp-1010103438980---101010343600-read-connection-reset-by-peer

按照下面的配置修改了sshd_config,重启sshd之后试了一下还是不行 :face_exhaling:

看看sudo配置情况


Defaults    env_reset
Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR LS_COLORS"
Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"

#
# Adding HOME to env_keep may enable a user to run unrestricted
# commands via sudo.
#
# Defaults   env_keep += "HOME"

Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin

## Next comes the main part: which users can run what software on 
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL

## Allows members of the 'sys' group to run networking, software, 
## service management apps and more.
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS

## Allows people in group wheel to run all commands
%wheel  ALL=(ALL)       ALL

## Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

## Allows members of the users group to mount and unmount the 
## cdrom as root
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

## Allows members of the users group to shutdown this system
# %users  localhost=/sbin/shutdown -h now

## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment)
#includedir /etc/sudoers.d
%superuser ALL=(ALL) NOPASSWD: ALL
opsadmin ALL=(ALL) NOPASSWD: ALL
admin ALL=(ALL) NOPASSWD: ALL

如果.ssh目录删除过或者rsa重新设置过的话,tiup使用的互信是在.tiup目录中的.ssh文件就可能远程权限不正确。这时把.ssh拷贝到.tiup下即可,详细可以参见专栏 - 解决tiup‘ssh: unable to authenticate’报错 | TiDB 社区

建议用root去做部署