Ssh – What are the commands to apply changes made to /etc/ssh/sshd_config

linuxsshsshd

I have made some changes to /etc/ssh/sshd file and wanted these effects should take place.
I know I can run below command for the effects to take place.

/etc/init.d/sshd reload

But on my box I could not find /etc/init.d/sshd itself.

So is there any other command can I run which is equivalent to

/etc/init.d/sshd reload 

Edit: I am on linux kernel 2.6.28 running on embedded development board.

Best Answer

Try:

$ sudo /etc/init.d/sshd restart

systemd

If that doesn't work and your using a distro such as Fedora/CentOS/RHEL and it's using systemd then try this:

$ systemctl sshd.service reload 

You can get all the commands that sshd.service will accept by doing this. Hit the Tab key after typing the following:

$ systemctl sshd.service 
cancel                 emergency              is-enabled             list-unit-files        reload-or-restart      start
condreload             enable                 is-failed              list-units             reload-or-try-restart  status
condrestart            exit                   isolate                load                   rescue                 stop
condstop               force-reload           kexec                  mask                   reset-failed           suspend
daemon-reexec          halt                   kill                   poweroff               restart                try-restart
daemon-reload          help                   link                   preset                 set-environment        unmask
default                hibernate              list-dependencies      reboot                 show                   unset-environment
delete                 hybrid-sleep           list-jobs              reenable               show-environment       
disable                is-active              list-sockets           reload                 snapshot               

If it's a Debian/Ubuntu system they use upstart to mange services, at least with the newer versions.

See my answer to this Q&A titled: How to “close” open ports?. I discuss your options for using upstart & systemd further in that answer.

Neither?

You could use kill to send the SIGHUP signal to the running process if none of the above are appropriate for your particular distro.

$ pkill -1 sshd

Will send signal 1 (SIGHUP) to the sshd process. If you don't have the pkill or pgrep family of commands you can use ps.

$ ps -eaf | grep sshd 1234

Then take that process ID and send it a signal using the kill command.

$ kill -1 1234

Signals

If you ever forget which ones are which you can use the kill command to find out via the -l switch.

Example

$ kill -l
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1
11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM
16) SIGSTKFLT   17) SIGCHLD     18) SIGCONT     19) SIGSTOP     20) SIGTSTP
21) SIGTTIN     22) SIGTTOU     23) SIGURG      24) SIGXCPU     25) SIGXFSZ
26) SIGVTALRM   27) SIGPROF     28) SIGWINCH    29) SIGIO       30) SIGPWR
31) SIGSYS      34) SIGRTMIN    35) SIGRTMIN+1  36) SIGRTMIN+2  37) SIGRTMIN+3
38) SIGRTMIN+4  39) SIGRTMIN+5  40) SIGRTMIN+6  41) SIGRTMIN+7  42) SIGRTMIN+8
43) SIGRTMIN+9  44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9  56) SIGRTMAX-8  57) SIGRTMAX-7
58) SIGRTMAX-6  59) SIGRTMAX-5  60) SIGRTMAX-4  61) SIGRTMAX-3  62) SIGRTMAX-2
63) SIGRTMAX-1  64) SIGRTMAX    

References

Related Question