[systemd-devel] Starting ssh from a systemd service

Thomas Köller thomas at koeller.dyndns.org
Tue Feb 14 22:31:57 UTC 2023


I cannot start the 'ssh' command from a systemd service. A very simple 
service file demonstrates the problem:


# /run/systemd/system/ssh-test.service

[Unit]

[Service]
Type = oneshot
ExecStart = /usr/bin/ssh -V


[root at raspi-400 ~]# systemctl start ssh-test.service
Job for ssh-test.service failed because the control process exited with 
error code.
See "systemctl status ssh-test.service" and "journalctl -xeu 
ssh-test.service" for details.
[root at raspi-400 ~]# systemctl status ssh-test.service
× ssh-test.service
      Loaded: loaded (/run/systemd/system/ssh-test.service; static)
      Active: failed (Result: exit-code) since Tue 2023-02-14 23:26:47 
CET; 8s ago
     Process: 11787 ExecStart=/usr/bin/ssh -V (code=exited, status=203/EXEC)
    Main PID: 11787 (code=exited, status=203/EXEC)
         CPU: 3ms

Feb 14 23:26:47 raspi-400 systemd[11787]: ssh-test.service: Failed at 
step EXEC spawning /usr/bin/ssh: Permission denied
Feb 14 23:26:47 raspi-400 systemd[1]: Starting ssh-test.service...
Feb 14 23:26:47 raspi-400 systemd[1]: ssh-test.service: Main process 
exited, code=exited, status=203/EXEC
Feb 14 23:26:47 raspi-400 systemd[1]: ssh-test.service: Failed with 
result 'exit-code'.
Feb 14 23:26:47 raspi-400 systemd[1]: Failed to start ssh-test.service.


Running the ssh command from the shell prompt works just fine:

[root at raspi-400 ~]# /usr/bin/ssh -V
OpenSSH_8.8p1, OpenSSL 3.0.8 7 Feb 2023





More information about the systemd-devel mailing list