SSH 将始终以 root 身份进行身份验证

SSH 将始终以 root 身份进行身份验证
# ssh -l admin 10.1.0.2
Warning: Permanently added '10.1.0.2' (RSA) to the list of known hosts.
[email protected]'s password: 

使用“OpenSSH_8.4p1 Debian-5+deb11u1,OpenSSL 1.1.1n”,我想连接到远程主机,但无论我怎么尝试,它总是将登录恢复为 root。配置文件已重命名,以确保未应用任何用户选项。我得到的唯一提示是这一行:

debug1: Authenticating to 10.1.0.2:22 as 'root'

- 编辑 -

为了提供更多信息,这里有一个调试输出,直到 SSH 决定以 root 身份进行身份验证,尽管被告知不要这样做。

xxxxxxx:~$ ssh -vvv -p4711 [email protected]
OpenSSH_8.4p1 Debian-5+deb11u1, OpenSSL 1.1.1n  15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug2: resolve_canonicalize: hostname xxx.xxx.xxx.xxx is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/xxx/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/xxx/.ssh/known_hosts2'
debug2: ssh_connect_direct
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 4711.
debug1: Connection established.
debug1: identity file /home/xxx/.ssh/id_rsa type -1
debug1: identity file /home/xxx/.ssh/id_rsa-cert type -1
debug1: identity file /home/xxx/.ssh/id_dsa type -1
debug1: identity file /home/xxx/.ssh/id_dsa-cert type -1
debug1: identity file /home/xxx/.ssh/id_ecdsa type -1
debug1: identity file /home/xxx/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/xxx/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/xxx/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/xxx/.ssh/id_ed25519 type -1
debug1: identity file /home/xxx/.ssh/id_ed25519-cert type -1
debug1: identity file /home/xxx/.ssh/id_ed25519_sk type -1
debug1: identity file /home/xxx/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/xxx/.ssh/id_xmss type -1
debug1: identity file /home/xxx/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4p1 Debian-5+deb11u1
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.4p1 Debian-5
debug1: match: OpenSSH_8.4p1 Debian-5 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to xxx.xxx.xxx.xxx:4711 as 'root'
debug3: put_host_port: [xxx.xxx.xxx.xxx]:4711
debug3: hostkeys_foreach: reading file "/home/xxx/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /home/xxx/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys from [xxx.xxx.xxx.xxx]:4711
debug3: order_hostkeyalgs: have matching best-preference key type [email protected], using HostkeyAlgorithms verbatim

如您所见,没有应用任何配置文件选项。最让我困惑的是,在使用相同 ssh 客户端版本的其他主机上,它可以正常工作。我仍然认为我遗漏了一些基本的东西。有什么想法吗?

谢谢。

答案1

抱歉,占用了您宝贵的时间...我已经找到导致此现象的原因:

alias ssh='ssh -l root -o "PreferredAuthentications publickey,password"'

不知道包在 /etc/bash.bashrc 中设置了这个别名。

亲切的问候...

相关内容