0

I setup restricted bash for a user (scriptsser) on Machine A and created symlinks to the desired commands as below

lrwxrwxrwx. 1 root root 10 Nov 28 08:09 touch -> /bin/touch
lrwxrwxrwx. 1 root root  8 Nov 28 08:09 ssh -> /bin/ssh
lrwxrwxrwx. 1 root root  7 Dec 18 07:44 mv -> /bin/mv

Everything works fine and I am able to use these commands while I am logged in to Machine A with this user (scriptsser)

My problem starts when I try to execute a command from a remote machine; say Machine B.

ssh scriptsser@MachineA -i /home/scriptsser/.ssh/id_rsa  "mv /file1 /file2" ;

I get the following error message.

rbash: /bin/rbash: restricted: cannot specify `/' in command names

What am I missing here?

9
  • It's right in the man page: specifying command names containing /, or specifying a filename containing a / as an argument to the . builtin command are both forbidden. Dec 19, 2019 at 1:29
  • right - but where did I specify a command with a leading slash @ajgringo619 ? In my remote command I only pointed to "mv" and not "/bin/mv", right?
    – user386967
    Dec 19, 2019 at 1:32
  • Ahh, but you are: mv = /bin/mv (per your symlink). Dec 19, 2019 at 1:40
  • Okay - I even tried copying the actual command /bin/mv to the user's home path and still getting the same result.
    – user386967
    Dec 19, 2019 at 1:49
  • I think the error has nothing to do with mv /file1 /file2. For some reason rbash is trying to run /bin/rbash. If it tried to run /bin/echo then the error would start with rbash: /bin/echo:. Compare rbash -c '/bin/echo' and rbash -c '/bin/rbash'. Dec 19, 2019 at 1:56

1 Answer 1

0

I realized I had '/bin/rbash' set in authorized_keys for the user "scriptsser".

1
  • It’s not clear to me that this answers the question.  If it does, please explain how.  (Please do not respond in comments; edit your answer to make it clearer and more complete.) Perhaps this should be an edit to the question? Dec 19, 2019 at 4:43

You must log in to answer this question.

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