Limit SSH User to a shell command

后端 未结 2 1801
忘了有多久
忘了有多久 2021-01-13 22:57

My question is

how can I allow an user to ssh to my server with limitation to a shell command and a directory?

My situation

I\'m using git to dep

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-13 23:49

    A simple command to disable the shell in a git user is to replace the /usr/bin/bash with /usr/bin/git-shell. Replace it in the /etc/password file or using the command:

    usermod -s /usr/bin/git-shell [username]
    

    Check this document from the official Git website: Setting Up the Server. Additional info if you want to have a shell on it but limiting it to a directory use: rbash. Same as git-shell just replace the user shell with it.

提交回复
热议问题