Senin, 12 September 2011

SSH ssh only allowing a specific command to be run

If you're a system administrator wanting to limit a specific command to a specific user, you can apply these lines to your sshd_config files


case : user monkey only allowed to use mongodb


--- edit sshd config file & adding rule ---

$ sudo nano /etc/ssh/sshd_config

Match User monkey
ForceCommand mongo localhost:27017/db

--- restart ssh service ---

$ sudo service sshd restart


NOW try login as user : monkey, you will be automatically execute mongodb. So user monkey endup logged via ssh to use mongodb and served a mongo prompt

$ ssh monkey@10.10.10.10
ssh monkey@10.10.10.10 password :
Could not chdir to home directory /home/laparlagi: No such file or directory
MongoDB shell version: 1.2.2
url: localhost:27017/db
connecting to: localhost:27017/db
type "exit" to exit
type "help" for help
>

--- if you type exit, then ssh connection will be terminated --

Tidak ada komentar: