Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
Did you try service ssh[d] restart? –  galegosimpatico Dec 12 '13 at 14:04
    
Yes I tried ,but it says no such command –  Rajan Pathak Dec 12 '13 at 14:10
1  
If you are using a custom bare and undistributed GNU/Linux system you may want to just kill sshd and reinvoke it after being found with find. –  galegosimpatico Dec 12 '13 at 14:20
    
@uprego your point made quite a sense ,let me try this –  Rajan Pathak Dec 12 '13 at 14:25
1  
@RajanPathak - yes that's the power of the SIGHUP. You're signaling the process to "hang up" as in a phone, but as soon as it hangs up it starts it self back up. Much like on a phone when you click the receiver to get a dial tone. When you press the button you "hang up" and when you release you get a dial tone. –  slm Dec 12 '13 at 15:04
show 5 more comments

3 Answers

up vote 3 down vote accepted

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

share|improve this answer
    
I tried it and mentioned in my question as well –  Rajan Pathak Dec 12 '13 at 14:12
    
@RajanPathak - see updates, also include your distro in the Q. –  slm Dec 12 '13 at 14:15
    
Sorry slm but systemctl sshd.service -bash: systemctl: command not found, this is what I got –  Rajan Pathak Dec 12 '13 at 14:23
    
@RajanPathak - see updates, show how to do it using kill and SIGHUP. –  slm Dec 12 '13 at 14:27
    
Thanks slm, let me try this –  Rajan Pathak Dec 12 '13 at 14:36
show 1 more comment

If you're using Ubuntu, it uses the Upstart method, so try the following:

sudo stop ssh
sudo start ssh

or 

sudo restart ssh
share|improve this answer
add comment

On Slackware, the way to do this is:

# /etc/rc.d/rc.sshd restart

As you're probably realizing, it really depends on your distro. But if you can't figure out what sort of system your have, and therefore how daemons are started and stopped, the comment from uprego might be your best bet.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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