0

I am trying to run a command (server-side) every time a user connects, so I set the ForceCommand keyword at the very bottom of the /etc/ssh/sshd_config file:

ForceCommand /bin/test 

where:

# cat /bin/test
#!/bin/bash

echo "1" >> ~/test.txt

/bin/bash

and

# ls -l /bin/test
-rwxr-xr-x 1 root root 47 Mar  8 10:15 /bin/test

To make it simple, I am trying to make it working for root user first, but nothing happens (after connecting, the test.txt file is not created in /root)

What am I doing wrong?

Thank you very much, Andrea

Using Ubuntu 14.04.6 LTS and OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.13, OpenSSL 1.0.1f 6 Jan 2014

10
  • How is it related to Ubuntu?
    – Pilot6
    Mar 8, 2019 at 9:25
  • see stackoverflow.com/a/33714333
    – cmak.fr
    Mar 8, 2019 at 9:32
  • @Pilot6 It's about configuration of an OpenSSH server, presumably running on an Ubuntu ststem.
    – fkraiem
    Mar 8, 2019 at 9:33
  • It doesn't look like an Ubuntu server ;-)
    – Pilot6
    Mar 8, 2019 at 9:33
  • I am sorry, forgot to mention my system details. I have appended it to the question.
    – Angus73
    Mar 8, 2019 at 10:37

1 Answer 1

0

Sorry, I found the problem. Simply I needed to restart ssh (service ssh restart) after editing the /etc/ssh/sshd_config file. Anyway, thanks for your help!

You must log in to answer this question.

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