Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting PID of sshd

Tags:

bash

shell

I am executing sshd in a bash script using

$ /usr/sbin/sshd

How do I get the process ID of this sshd that I executed?

like image 370
i0exception Avatar asked Sep 08 '25 00:09

i0exception


1 Answers

sshd will typically write a PID file; by default this is at /var/run/sshd.pid. You can use this to find the process ID of the listening sshd process. You should be aware that sshd may fork several subprocesses as it works, so what you want really depends on what you intend to do with it.

like image 94
Jeremy Roman Avatar answered Sep 10 '25 08:09

Jeremy Roman