I am running kali linux.

When I do sudo systemctl start ssh and try to verify with sudo ss -tlp I get the following:

kali@kali:~$ sudo ss -antlp
State                   Recv-Q                  Send-Q                                   Local Address:Port                                   Peer Address:Port                 Process                                           
LISTEN                  0                       128                                                                  *                     users:(("sshd",pid=12926,fd=3))                  
LISTEN                  0                       128                                               [::]:22                                             [::]:*                     users:(("sshd",pid=12926,fd=4))   

So the service is running, however if I run sudo systemctl list-unit-files | grep ssh I get the following:

kali@kali:~$ sudo systemctl list-unit-files  | grep ssh
ssh.service                                                      disabled       
ssh@.service                                                     static         
ssh.socket                                                       disabled       
rescue-ssh.target                                                static  
ssh.socket                                                       disabled       

So it is not running, what am I missing here:

  1. Is ssh and ssh.service not the same thing ?
  2. When I run sudo systemctl start ssh am I running a service or something else ?
  • After you start ssh (and it is a service) what does systemctl status ssh return? – ajgringo619 Sep 22 '20 at 18:04
  • @ajgringo619, it shows active, I figured it out, there is a difference between having the service running and having it enabled, which is running it automatically at system start up. – Moha the almighty camel Sep 22 '20 at 18:09

I misunderstood the output of systemctl list-unit-files.

My service is running as per ss -tlp output, but it is not enabled by default at run time, as shown by systemctl list-unit-files.

Running sudo systemctl enable ssh marks the service as enabled at start up and the output of systemcetl list-unit-files shows that.

  • 1
    Please note that systemctl enable X.service will only trigger the start of the service according to the [Install] section. While this in most cases means at startup, this could also be e.g. when a GUI is started, when a user logs in, or upon request by another service (which possibly could only be manually started). Just to make you aware. – FelixJN Sep 22 '20 at 21:27
  • @Fiximan, I wasn't aware of that. thank you! – Moha the almighty camel Sep 23 '20 at 6:30
  • @Fiximan, do you know which option in [Install] section is determines when the service starts ? I can't find an answer to it here: freedesktop.org/software/systemd/man/systemd.unit.html – Moha the almighty camel Sep 23 '20 at 6:39
  • All do, you can define multiple dependencies. E.g. WantedBy=default.target means "Activate at startup", using graphical.target, would activate when a GUI starts, B.service means when B is started it is triggered. The PartOf=B.service means when B is started or stopped it will be started or stopped, too, RequiedBy=B.service means it will be started with B and if it fails, B will fail. Often it's the inverse of using e.g. Wants= or Requires= in B directly, e.g. if you do not want to alter B.service for some reason. Check special units for e.g. linking to startup or network. – FelixJN Sep 23 '20 at 9:10

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.