you have two important commands in Solaris
svcadm, and svcs. An easy Mnemonic is service admin, and service status, respectively.
svcadm is the solaris equivalent of the linux service while the svcs command can be said to be the equivalent of the service status command.
So, for the sake of demonstration, so we accidentally threw the following line into our SSH config file (/etc/ssh/sshd_config):
so now we have the following in our config file:
... # Banner to be printed before authentication starts. #Banner /etc/issue Hello Dreamincode! # Should sshd print the /etc/motd file and check for mail. # On Solaris it is assumed that the login shell will do these (eg /etc/profile). PrintMotd no ...
then, we restart our service:
svcadm restart ssh
it will then spit out the following error:
bash-3.00# Dec 31 14:15:06 HOSTNAME svc.startd: net work/ssh:default failed: transitioned to maintenance (see 'svcs -xv' for details)
Now isn't that nice? It gave us the next step to troubleshoot the issue.
so, instead of svcs -xv (which will give us the status of ALL failed services) we only care about ssh, so will do the following:
svcs -xv ssh
bash-3.00# svcs -xv ssh svc:/network/ssh:default (SSH server) State: maintenance since Mon Dec 31 14:15:06 2012 Reason: Start method failed repeatedly, last exited with status 255. See: http://sun.com/msg/SMF-8000-KS See: man -M /usr/share/man -s 1M sshd See: /var/svc/log/network-ssh:default.log Impact: This service is not running.
man svcs gives us the following explanation:
-v Without -x, displays verbose columns: STATE, NSTATE, STIME, CTID, and FMRI. With -x, displays extra information for each explanation. -x Displays explanations for service states. Without arguments, the -x option explains the states of services which: o are enabled, but are not run- ning. o are preventing another enabled service from running.
so, that is informative. It is set to maintenance. To find out why, we'll check the log it gave us:
to cut out all the other stuff and get to the relevant:
[ Dec 31 14:15:06 Executing start method ("/lib/svc/method/sshd start") ] /etc/ssh/sshd_config: line 65: Bad configuration option: Hello /etc/ssh/sshd_config: terminating, 1 bad configuration options [ Dec 31 14:15:06 Method "start" exited with status 255 ]
so, we now know that we have an error in our config on line 65.
since I am using vi, I will enter the following: :set nu to display line number, and scroll down to line 65 in our sshd_config.
After I delete the line in the config, and save the file, I'll clear the maintenance status of the service:
svcadm clear ssh
then restart it for good measure:
svcadm restart ssh
now, if we look at the status of our service:
bash-3.00# svcs ssh STATE STIME FMRI online 14:29:45 svc:/network/ssh:default