Allow Execution Of Commands Via SSH But Not To Login

Home » CentOS » Allow Execution Of Commands Via SSH But Not To Login
CentOS 4 Comments

Hi,

Is there a way to allow a user to execute commands via ssh, for example:
“ssh user@server ls”, but disallow the same user to login on this server with “ssh user@server” ?

Thanks, Bernard

4 thoughts on - Allow Execution Of Commands Via SSH But Not To Login

  • Google “ssh restrict to single command”.

    First hit covers using the command option in authorized_keys.

    jh

  • Hi,

    you can use the option command your /home/user/.ssh/authorized_keys .

    for example :

    command=”cd /some_where; other command , ssh-rsa key …..”

    Le 11/01/2017

  • Hello Bernard,

    Only way to learn is from your mistakes ;-) .

    If you need interactive login for f.e. sftp you should have a look at rssh. It allows only scp, sftp, cvs, rdist and rsync. It’s probably not too hard to patch in other commands if you would need those.

    A little netiquette: Please don’t top post, it makes the flow of the conversation unclear. A little trimming of the text you reply to is also appreciated. Especially signatures do not provide any context so they should always be removed. Thanks.

    Regards, Leonard.