I want to use the AuthorizedKeysCommand as a test on my server.
1. Added the line AuthorizedKeysCommand /etc/ssh/myScript.sh to the end of the file.
2. Created a script myScript.sh in the /etc/ssh/ location that contains:

echo "Hello world";

This script has permissions 755 and is owned by root with group set to sshd.

  1. Tried to restart the SSHD daemon by running: sudo systemctl restart sshd

sshd does not restart and exits. The error code too is not clear and does not go away until the AuthorizedKeysCommand is removed.

Where am I going wrong?

I am running SSH version: OpenSSH_6.6.1p1 OpenSSL 1.0.1e-fips 11 Feb 2013 on a Centos7 server.

  • What is the error message you get when you restart sshd? – Abhijeet Kasurde Mar 10 '16 at 8:26

Indeed, an error message would be useful, but I take a wild guess and maybe this happened:

systemd[1]: Started OpenBSD Secure Shell server.
sshd[23748]: AuthorizedKeysCommand set without AuthorizedKeysCommandUser
systemd[1]: ssh.service: main process exited, code=exited, status=255/n/a

You need to the set the AuthorizedKeysCommandUser parameter as well, otherwise sshd fails to start. Also, make sure to heed all the other requirements for AuthorizedKeysCommand laid out in sshd_config, e.g. the script needs to be executable too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.