image
image
Ticket Options
Question Details
TICKET ARCHIVE -> Running Sshd As a Daemon Not Through Launchd In Tiger And Panther
melba - Aug 6, 2005 - 2:49 pm
image
image
I use ssh a lot for transfering files to and from school and I find the start up time for sshd under the new launchd takes too long. Anyway I can start it up running as a daemon instead?
macbri - Aug 7, 2005 - 12:28 am
image
image
Hi Melba -

My name is Brian and I'll be helping you today.

First off, you can indeed run sshd without resorting having it launched "on demand". You can open a terminal and type "sudo sshd" to run the daemon in the background. Note that you should turn OFF "Remote Login" in the "Sharing" Systems Preferences first to avoid any conflict.

You don't have to run sshd yourself though, whenever you boot your mac you can have it run automatically for you. Here's an excerpt from a reply I gave some time ago, where the question was how to start a daemon automatically at startup. It was for starting imapd so I've edited it to reflect that it's for sshd this time.

First, make a "/Library/StartupItems" directory if it doesn't already exist. (Note that you'll find a "/System/Library/StartupItems/" directory on your system also, this is reserved for OS X services).

Inside your /Library/StartupItems make an Sshd directory (i.e. "/Library/StartupItems/Sshd"). There are at minimum 2 things that need to go inside this directory: the script to start & stop the sshd server, and a "StartupParameters.plist" which defines certain parameters for the daemon. The script then is written with specific functions in place, e.g. StartService and StopService. The script must have the same name as the directory it's in, in this case it would be "/Library/StartupItems/Sshd/Sshd". If you find other directories in /Library/StartupItems you can use their contents as templates for your daemon. If not, there's a great O'Reilly article that explains the process in detail and shows examples of the required files. You can read it at
http://www.macdevcenter.com/pub/a/mac/2003/10/21/startup.html

I hope this helps!
Thanks for using macosx.com

- Brian

--------
Brian S.
MacOSX.com Technical Support
brian@macosx.com
melba - Aug 26, 2005 - 5:58 pm
image
image
Brian,

thank you for your help. i got sshd up and running with not waiting very quickly.

the two files that i wrote are below and i do have a couple of more questions.

sshd line 7 . /etc/hostconfig ## should this be changed to sshd_config? and what does this do?

sshd line 32 runservice "$1" ## do i need this?

also i notice alot of invisable files that begin with .??? and . with a string of radom letters and numbers or .09:56:34.

i have trashed them and they come back. i have not seen these on any of the other mac's i have.

i ran virex on them and nothing. i was download a lot of stuff setting up this new g% with tiger 10.4 on it.

did i pick up something and if so how do i go about getting rid of it.

thanks,

melba


startupparameters.plist:





description
sshd
messages

start
starting sshd
stop
stopping sshd

orderpreference
none
provides

sshd




sshd:

#!/bin/sh
##
# adobe version cue ## i should change this to sshd server or the like ?
##

. /etc/rc.common
. /etc/hostconfig ## should this be changed to sshd_config?

startservice ()
{
if [ `/usr/bin/grep -c "sshdserver=-yes-" "/etc/hostconfig"` == 1 ]; then
consolemessage "starting sshd daemon"

(
/usr/sbin/sshd
)
fi
}

stopservice ()
{
consolemessage "stopping sshd daemon"
killall -quit sshd
}

restartservice ()
{
consolemessage "restarting sshd daemon"
killall -hup
}

runservice "$1" ## do i need this?


list of wierd files:

/.trashes/.\?\?\?\?\?\ rdk4n9idcx5oiczs36a9f0i75\ \?\?\?\?
/library/caches/.09:56:34\ -\ 25.08.2005\ 8d-162ikmh.log
/library/preferences/.09:56:34\ -\ 25.08.2005\ -2olsegb6r.log
/library/preferences/.09:56:34\ -\ 25.08.2005\ 13a011he9f.log
/library/preferences/.\?\?\?\?\?\ q2m6pjcl7hfss0uc-36ab-bgl\ \?\?\?\?
/library/receipts/.09:56:33\ -\ 25.08.2005\ -pmzpmamww.log
/library/receipts/.5diztpcguz0giao7s9tcnv6-111elxwmok8r
/library/receipts/.\?\?\?\?\?\ iijtp9di763ae06y3648f0w4s\ \?\?\?\?
/library/receipts/.\?\?\?\?\?\ kvyprsbkbuq8vvuq-f8mmepxp\ \?\?\?\?
/library/receipts/.b3iu8vr18bemdtkcgyy30hb-111ec5h9kudj
/cores/.gshphjfrqrhwavtw0xtmwdxfix9g1ksba3yk
/cores/.mgvckdgq5qcsfkzccilpobukacuaclqkm7sb
/cores/.xuxwlegf1vi8b5ffnu6mhupjh880j7j0r1dl
/cores/.ubbzdidikrubcixwja9cpd1ba386mpardrw4
/private/etc/.09:56:33\ -\ 25.08.2005\ -knlnnbcm4.log
/private/etc/.njdstxtndwypeow4bpfhpmjwf0d403ibglrw
/private/var/db/.\?\?\?\?\?\ ueuykoahkkqo06vy-9zzdnjkw\ \?\?\?\?
/private/var/db/netinfo/.09:56:34\ -\ 25.08.2005\ c8-161dijd.log
/private/var/db/netinfo/.\?\?\?\?\?\ rgqgc6en5fns59dq-d30t3w0x\ \?\?\?\?
/private/var/db/netinfo/local.nidb/.09:56:34\ -\ 25.08.2005\ 13c55dcabs.log
/private/var/log/.\?\?\?\?\?\ fajkk2hvwaq6flli-36fe-yob\ \?\?\?\?
/private/var/log/.gzmjqfmp1gxohe3w6bxmrz3f4f235fd85vne
/private/var/spool/.09:56:34\ -\ 25.08.2005\ -1dwrefy6f.log
/private/var/spool/.09:56:34\ -\ 25.08.2005\ -yzaxueyux.log
/private/var/spool/.6s0rkrenqetcgmsvz7flzpttm0k7qlgtdzb9
/private/var/spool/.\?\?\?\?\?\ soip8dfcxycrhf3f-uwwwp8n0\ \?\?\?\?
macbri - Aug 29, 2005 - 2:43 am
image
image
Hi Melba -

So your startupparameters.plist file looks fine. Although to be complete you might want to add a section that says it depends on "network": (I'm substituting square for angled brackets here so it will show on the web, be sure to change them to normal angle- brackets if you cut-n-paste):

[key]Uses[/key]
[array]
[string]Network[/string]
[/array]


On to the startup script. First off, yes I'd recommend you change the comment at the top that reads "adobe cue", to something like "ssh server" as you suggest. This isn't necessary since it's just a comment, but it makes everything clear if you go back in 12 months to review what you had done.

>> sshd line 7 . /etc/hostconfig ## should this be changed to sshd_config? and what does this do?

No - this is correct as it is. It tells your startup script to execute a file called /etc/hostconfig, which is basically a list of services which should or shouldn't be run at startup. You'll see a bunch of lines like:

WEBSERVER=-YES-
SMBSERVER=-NO-

With properly written startup scripts you can basically decide whether services should start or not at startup - in the above example my web server does start but the smb server does not. So as you probably figured out you need a line that reads:

SSHDSERVER=-YES-

in your /etc/hostconfig. The added bonus is that you can change this to "-NO-" if you don't want sshd to run at startup in the future. On a related note, the line which reads:

if [ `/usr/bin/grep -c "sshdserver=-yes-" "/etc/hostconfig"` == 1 ]; then

means that the script searches for the /etc/hostconfig setting. This makes the ". /etc/hostconfig" on line 7 redundant. You could remove line 7, or you could shorten the line above to:

if [ "$SSHDSERVER" = "-YES-" ] ; then


>> sshd line 32 runservice "$1" ## do i need this?

Yes - this is the guts of the script, which will execute the correct subroutine (StartService, StopService, etc.) depending on it's provided argument.

By the way, your RestartService() routine says "killall -HUP" it should probably read "killall -HUP sshd".


Finally, the temporary files you see are not related to this issue as far as I can tell. It sounds as though some software is writing a bunch of temporary files over time. Have you looked at the contents of one of these files? it may give some clue as to where they are coming from. If "more' gives nothing but gibberish, try the "strings" command.

- Brian

--------
Brian S.
MacOSX.com Technical Support
brian@macosx.com
melba - Aug 30, 2005 - 7:21 pm
image
image
Brian,

thanks for the input on the scripts. i changed them. i ran the strings command on the funny files i found and pasted the output below. note, i made a change to the hostconfig flat file changing hostname=-automatic- to hostname=g5 and it crashed the qmasterd. so i changed it back. qmasterd does not crash anymore on startup or reboot. maybe is is where they are coming from or i am also having a problem with audio cd when i put them in the cddafs.util crashes and still does.

the out put from strings.

wa{3
o/>mo
x.re
clz/
2kme-
4h47
,kcu
,q1ai
2co
x.z\
2kk1-
4h47
,kcu
@`)y6
'lh|8
#sw
//ka
kaj3
5d?mh,
zqc=i
fet^
57$g
v?qax
,kcu
@g7`
`@@og@6vjzj
td$3$
zvjtd
jv]c
y=r/
oho0
!"q@
fet^
57$g
v?qax
,kcu
y&7:
jy6{
;gx)
^"$j{s5i
y5w9dp
z$fb
{qa{$q
e~jl
9a-z
{aj3
4h57,g
ie8a
vymzzc9:]
rmfb
y471q"
[ey35
!>/f
x.]\
4h57,g
,kcu
ze5td
n`?:m"
fe^31`
5u9xc1
n"na
4h57,g
it$"
$fr/
1}r8b
!=yw
k!k?g
4h57,g
b?qax
k"c9zx}
,kcu
+&g,
u|czvp
njl#+
k|r[
x.>\
4h57,g
b?qax
k"c9zx}
,kcu
ze5td
n`?:m"
4h57,g
b?qax
k"3;zx}
ie8a
vy.z4c9
q2zw4
)qu ?c
f+{c
;*?9iig8a
vyzzzc9z
)qvm?c
x.|7
,kcu
@/n96
!e"w
ebgh
y3ew-
,kcu
y&7:
jy6{
;gx)
^"$j{s5i
y5w9dp
z$fb
{qa{$q
e~jl
macbri - Aug 31, 2005 - 5:10 pm
image
image
Hi Melba -

The output of 'strings' didn't really tell us anything other than the files contain binary data. I doubt this is anything virus related and is much more likely to be related to some software package or system you have installed on your system (qmasterd being an example). When running your usual set of apps on your system, you might be able to tell which of those many files has been modified recently. Then in a terminal run the "/sbin/lsof" command, which gives you a list of all open files, and the process which has opened them. This might clear up the mystery a little. If you do this, make sure you make your terminal window as big as possible since you'll get a lot of output from "lsof" -- and you might also want to redirect the output to a file you can view with Textedit or whatever, e.g.:

/sbin/lsof > ~/Desktop/lsof.txt

Finally, regarding your cddfs.util problem, I'd suggest submitting a new ticket to macosx.com explaining the problem. This is only because it's a different problem well outside the scope of the original sshd request, and I or another tech here will be happy to pursue it with you. Also, all resolved tickets become part of the searchable database here on macosx.com, so having a new ticket with the problem in hand will help out potentionally lots of other users with similar problems.

- Brian
--------
Brian S.
MacOSX.com Technical Support
brian@macosx.com
melba - Aug 31, 2005 - 7:16 pm
image
image
Thanks

IF THIS IS YOUR QUESTION AND YOU WISH TO RESPOND, LOGIN HERE FIRST.


Search Engine Friendly URLs by vBSEO 3.1.0