3

How to create a new user that can login via SSH, but can't use shell commands? I've tried to set /bin/false as the default shell to the user, but then I no longer can login via SSH.

3
  • 1
    What's the point in logging in via ssh if it's not possible to run commands? Apr 2, 2014 at 0:30
  • The only other thing remaining is using specified port forwards to do something else. Apr 2, 2014 at 1:47
  • Make a temporary httpforward. We need it for some users sporadically access.
    – Victoralm
    Apr 2, 2014 at 1:48

1 Answer 1

3

You can create a new, small, "shell" (I used quotes because is not a real shell) as follow:

  1. As root, create a new file in /bin directory, let say fakesh.

  2. Add the following code inside /bin/fakesh file:

    #!/bin/bash
    echo -n "$ "
    while read cmd ; do 
        if [ "$cmd" = "exit" ]; then break; fi
        if [ "$cmd" != "" ]; then echo "The only one available command is: exit"; fi
        echo -n "$ "
    done
    
  3. Save the file and make it executable for everyone:

    chmod +x /bin/fakesh
    

After these, just set /bin/fakesh as the default shell for your user. The user will be available to login his account via ssh, but he will not be able to execute any command except for exit.

1
  • 1
    That was amazing!! The better ideas is really the simplest ones !!
    – Victoralm
    Apr 2, 2014 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .