Allow user to set up an SSH tunnel, but nothing else

后端 未结 10 2144
小蘑菇
小蘑菇 2020-12-22 16:47

I\'d like to allow a user to set up an SSH tunnel to a particular machine on a particular port (say, 5000), but I want to restrict this user as much as possible. (Authentica

10条回答
  •  佛祖请我去吃肉
    2020-12-22 17:08

    Here you have a nice post that I found useful: http://www.ab-weblog.com/en/creating-a-restricted-ssh-user-for-ssh-tunneling-only/

    The idea is: (with the new restricted username as "sshtunnel")

    useradd sshtunnel -m -d /home/sshtunnel -s /bin/rbash
    passwd sshtunnel
    

    Note that we use rbash (restricted-bash) to restrict what the user can do: the user cannot cd (change directory) and cannot set any environment variables.

    Then we edit the user's PATH env variable in /home/sshtunnel/.profile to nothing - a trick that will make bash not find any commands to execute:

    PATH=""
    

    Finally we disallow the user to edit any files by setting the following permissions:

    chmod 555 /home/sshtunnel/
    cd /home/sshtunnel/
    chmod 444 .bash_logout .bashrc .profile
    

提交回复
热议问题