I have a SSH + LDAP installation with users public keys stored in LDAP.

I want that when some user in a list (configured into server) do a ssh connection with ssh user@server always log in as root. user user not exists on server, only on LDAP.

Now I have working this steps if I have configured my LDAP uid as root and ssh connection is ssh root@server.

But I need to login with ssh user@server.

Is SSH able to do this map?

Moved from StackOverflow.


On the SSH server, try adding the following line to bottom of /etc/passwd for the ldap user:


(replace user with the ldap username)

This will map the username user to root. I know it works if you have a corresponding entry in the shadow file and log in using that type of auth. So hopefully will work without the shadow entry for LDAP.

  • Users should not exists on server, only on LDAP, and once checked public key, must be log in as root. Maybe is not possible. – Lito Mar 14 '17 at 20:51
  • With my answer the user does not really exist on the server. Is just a mapping to root. – bao7uo Mar 14 '17 at 23:25
  • Yes, but I need to configure the "virtual" user in /etc/passwd. I need some solution only LDAP dependent. Thanks anyway :) – Lito Mar 15 '17 at 8:44
  • 1
    AFAIK it's not possible the way you want :-) – bao7uo Mar 15 '17 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.