我一直在对 ssh (openssh) 和 radius 进行大量研究。
我想做的事:
使用存储在 radius 服务器或 ldap 存储中的凭据(用户名和密码)通过 SSH 连接到设备。我一直在网上阅读,有些人指出在您的 radius 服务器的后台运行 ldap 服务器。这将起作用,但仅当在本地计算机中找到用户时才会起作用。
问题:有没有办法让我通过包含凭据的 radius 服务器登录来 ssh(或 telnet)到我的设备?如果没有,客户端(我尝试连接的机器)是否有办法获取更新的凭据列表并将其从中心位置存储在本地(无论是半径服务器还是 sql 数据库等)。
我已经能够通过 Radius 进行连接,但仅限于本地帐户,但例如,如果我尝试连接本地不存在的帐户(客户端),我会得到“不正确”
这是半径输出:代码:
rad_recv: Access-Request packet from host 192.168.4.1 port 5058, id=219, length=85 User-Name = "klopez"
User-Password = "\010\n\r\177INCORRECT"
NAS-Identifier = "sshd"
NAS-Port = 4033
NAS-Port-Type = Virtual
Service-Type = Authenticate-Only
Calling-Station-Id = "192.168.4.200"
代码:
[ldap] performing user authorization for klopez[ldap] WARNING: Deprecated conditional expansion ":-". See "man unlang" for details
[ldap] ... expanding second conditional
[ldap] expand: %{User-Name} -> klopez
[ldap] expand: (uid=%{Stripped-User-Name:-%{User-Name}}) -> (uid=klopez)
[ldap] expand: dc=lab,dc=local -> dc=lab,dc=local
[ldap] ldap_get_conn: Checking Id: 0
[ldap] ldap_get_conn: Got Id: 0
[ldap] performing search in dc=lab,dc=local, with filter (uid=klopez)
[ldap] No default NMAS login sequence
[ldap] looking for check items in directory...
[ldap] userPassword -> Cleartext-Password == "somepass"
[ldap] userPassword -> Password-With-Header == "somepass"
[ldap] looking for reply items in directory...
[ldap] user klopez authorized to use remote access
[ldap] ldap_release_conn: Release Id: 0
++[ldap] returns ok
++[expiration] returns noop
++[logintime] returns noop
[pap] Config already contains "known good" password. Ignoring Password-With-Header
++[pap] returns updated
Found Auth-Type = PAP
# Executing group from file /etc/freeradius/sites-enabled/default
+- entering group PAP {...}
[pap] login attempt with password "? INCORRECT"
[pap] Using clear text password "somepass"
[pap] Passwords don't match
++[pap] returns reject
Failed to authenticate the user.
WARNING: Unprintable characters in the password. Double-check the shared secret on the server and the NAS!
Using Post-Auth-Type Reject
# Executing group from file /etc/freeradius/sites-enabled/default
+- entering group REJECT {...}
[attr_filter.access_reject] expand: %{User-Name} -> klopez
attr_filter: Matched entry DEFAULT at line 11
++[attr_filter.access_reject] returns updated
Delaying reject of request 3 for 1 seconds
我还安装了 pam_radius,并且它可以正常工作(可以登录本地存在的帐户)。虽然我读了这篇文章,但不知道这是否 100% 准确:
http://freeradius.1045715.n5.nabble.com/SSH-authendication-with-radius-server-fails-if-the-user-does-not-exist-in-radius-client-td2784316.html 和 http: //fhf.org/archives/713
tl:dr:我需要 ssh 到本地没有用户/密码的机器,并且该组合将远程存储,例如半径服务器或 ldap。
请指教
附言
该解决方案最好使用 radius 服务器或 ldap,但不是必需的。如果有替代品,请告知。
谢谢,
凯文