![更改默认端口后无法使用 LDAP 帐户通过 SSH 登录](https://linux22.com/image/671154/%E6%9B%B4%E6%94%B9%E9%BB%98%E8%AE%A4%E7%AB%AF%E5%8F%A3%E5%90%8E%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%20LDAP%20%E5%B8%90%E6%88%B7%E9%80%9A%E8%BF%87%20SSH%20%E7%99%BB%E5%BD%95.png)
我更改了 CentOS7 安装上的 ssh 默认端口。但我无法使用 ldap 帐户连接到服务器。我收到“连接被拒绝”和以下错误:
Nov 16 16:43:52 server sshd[26297]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty=ssh ruser= rhost=localhost
Nov 16 16:43:59 server sshd[26308]: Invalid user random2 from ::1
Nov 16 16:43:59 server sshd[26308]: input_userauth_request: invalid user random2 [preauth]
Nov 16 16:44:04 server sshd[26308]: pam_unix(sshd:auth): check pass; user unknown
Nov 16 16:44:04 server sshd[26308]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=localhost
Nov 16 16:44:07 server sshd[26308]: Failed password for invalid user random2 from ::1 port 58711 ssh2
防火墙已关闭并且我已启用非默认端口。
我不知道这个“无效用户”是什么意思,因为我能清楚地看到他。
希望有人能有个主意。
提前致谢。
最真诚的
双手
编辑1:nsswitch.conf
passwd: files sss ldap
shadow: files sss ldap
group: files sss ldap
/etc/openldap/ldap.conf
URI ldap://servername.example.com/
BASE dc=example,dc=com
TLS_REQCERT allow
編輯2
ssh -vv -p 2431 random2@localhost
OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 56: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [::1] port 2431.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
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.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: [email protected],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: [email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected],[email protected],[email protected],[email protected],[email protected],ssh-ed25519,ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],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: [email protected],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,ecdsa-sha2-nistp256,ssh-ed25519
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,[email protected],[email protected],[email protected],aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],hmac-md5,hmac-sha1,[email protected],[email protected],hmac-sha2-256,hmac-sha2-512,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit:
debug2: kex_parse_kexinit: first_kex_follows 0
debug2: kex_parse_kexinit: reserved 0
debug2: mac_setup: setup [email protected]
debug1: kex: server->client aes128-ctr [email protected] none
debug2: mac_setup: setup [email protected]
debug1: kex: client->server aes128-ctr [email protected] none
debug1: kex: [email protected] need=16 dh_need=16
debug1: kex: [email protected] need=16 dh_need=16
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
debug1: Host '[localhost]:2431' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug2: kex_derive_keys
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: Roaming not allowed by server
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,password
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: Next authentication method: password
random2@localhost's password:
debug2: we sent a password packet, wait for reply
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
random2@localhost's password:
编辑2:
Nov 18 17:30:01 peacock systemd: Created slice user-0.slice.
Nov 18 17:30:01 peacock systemd: Starting Session 329 of user root.
Nov 18 17:30:01 peacock systemd: Started Session 329 of user root.
Nov 18 17:30:01 peacock nslcd[2917]: [45d5c5] <passwd="root"> ldap_result() failed: No such object
Nov 18 17:30:01 peacock nslcd[2917]: [16f79a] <group/member="root"> ldap_result() failed: No such object
Nov 18 17:30:01 peacock nslcd[2917]: [16f79a] <group/member="root"> ldap_result() failed: No such object
Nov 18 17:30:01 peacock nslcd[2917]: [c8c7c2] <group/member="gdm"> ldap_result() failed: No such object
Nov 18 17:30:01 peacock nslcd[2917]: [c8c7c2] <group/member="gdm"> ldap_result() failed: No such object
Nov 18 17:30:01 peacock nslcd[2917]: [f31d87] <group/member="gdm"> ldap_result() failed: No such object
这是怎么回事?我的整个 /var/log/messages 里都是这个。
答案1
看起来您正在尝试使用本地密码文件而不是 LDAP 服务器进行身份验证。
在客户端机器上检查:
- /etc/ldap.conf 和 /etc/openldap/ldap.conf --> LDAP 服务器和基本搜索必须正确定义。
- /etc/nsswitch.conf --> 搜索密码、组和影子定义。它们必须包含“ldap”:
passwd: ldap compat group: ldap compat shadow: ldap compat
增加详细程度会有很大帮助。使用 -v -vv -vvv 开关进行连接并查找身份验证信息:
ssh -vv user@host
答案2
好吧,这实际上不是一个解决方案,但它不知怎么就成功了。昨天我尝试了不同的方法来解决这个问题,我意外地删除了 /etc,我的服务器也挂了,不过我只是从头开始重新安装了它。并以完全相同的方式、相同的文件和相同的程序设置了 slapd。它成功了。我不知道问题出在哪里,但无论如何还是谢谢你的帮助。