Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to set up sshd to do some funky things on a dedicated server. (Which is to say, don't worry about why I'm asking such a strange question; I'm just experimenting to see how I can abuse OpenSSH.)

I'd like to allow a user to log into the system using a made-up name. For instance:

$ ssh joeschmoe@crazysshserver.com

where there's no (UNIX) user on the system named joeschmoe.

When they connect, I'd like them to be logged in as a user which does exist, named guest, and have something in the environment set to joeschmoe so I know who they logged in as.

Is it possible to decouple the notions of UNIX-user and ssh-user?

share|improve this question
    
is this helpful? - serverfault.com/questions/245033/… –  ultrasawblade Sep 5 '12 at 16:42
    
No, that's the config for ssh, the client. That would let the user type something different, but ultimately ask the server to log them in as a real user. I'm looking for a way for the client to ask to log in as a non-existent user, and have the server decide what user should own the shell that runs. –  Peeja Sep 6 '12 at 3:30
    
You would have to monkey around with the systems authentication services (PAM?) to permit unknown users. Major undertaking. –  Yedric Sep 17 '12 at 18:09
    
Yep. I'm fine with that. Assume I know how to write a PAM module. Is it possible? –  Peeja Sep 17 '12 at 19:24

1 Answer 1

  1. Install: libpam-script

  2. Add to /etc/pam.d/sshd the following: auth optional pam_script.so

  3. Edit /usr/share/libpam-script/pam_script_auth and make it this:

    #!/bin/bash adduser $PAM_USER --disabled-password --quiet --gecos ""

  4. Make it +x via: chmod +x /usr/share/libpam-script/pam_script_auth

  5. Be happy.

share|improve this answer
    
Won't that add them as a UNIX user? I don't want them to create a new UNIX user; I want them to be logged in as guest. –  Peeja Aug 24 at 14:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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