Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #175116
| From | Nemeth Gyorgy <friczy@freemail.hu> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: How to get ssh to run in daemon script |
| Date | 2016-11-27 14:00 +0100 |
| Message-ID | <sI7dM-4ot-7@gated-at.bofh.it> (permalink) |
| References | <sI5vj-3xy-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
2016-11-27 11:55 keltezéssel, Russell Gadd írta:
> I am trying to add a command into a script to shut down my NAS when
> the UPS detects a power loss. There is a daemon apcupsd which gets a
> signal from the UPS and runs various scripts which can be modified by
> the user.
>
> I have a script doshutdown as follows
>
> #!/bin/sh
> ... various messages and sleep delays
> /usr/bin/ssh root@nasbox poweroff
> ... more messages and sleep delays
>
> The ssh command in my script does not run in a power off test
> (everything else in the script works i.e. the messages and delays),
> but if I run the ssh command interactively from the usual graphical
> terminal (as root) it shuts down the NAS, so the NAS isn't stopping it
> working assuming its getting the appropriate handshaking from ssh.
>
> My knowledge of how to get daemon scripts working and how to use ssh
> is almost nil. Also I can't find a way to get any error output which
> the ssh command might be issuing. I've tried enclosing the body of the
> script in brackets to redirect output to files:
> {
> } > /data/temp/shutdown-out.txt 2> /data/temp/shutdown-err.txt
>
> I've looked in syslog, kern.log and auth.log without finding anything.
>
> So I'm scrambling around in the dark. Currently my vague ideas as to
> what might be wrong are:
>
> script doesn't know what nasbox is (it is defined in /etc/hosts)
> ssh is being run without being associated as root
> ssh cannot find root's keys
> nas doesn't recognise login as authorised user
>
> I'm also starting to think I am stressing the UPS too much by running
> too many power off tests, so I'd like to resolve this without too much
> more experimentation.
>
> Grateful for any suggestions. I'm running Linux Mint 17.3 (based on
> Ubuntu 14.04, based on Jessie). Uses openssh (1:6.6p1-2ubuntu2.8)
What user runs the daemon? If it is a separate user then run the ssh
with that user interactively. If the user does not have the
~/.ssh/known_hosts file or the destination host is not in it, then you
will have problems.
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to get ssh to run in daemon script Russell Gadd <russ.mail.lists@gmail.com> - 2016-11-27 12:10 +0100
Re: How to get ssh to run in daemon script Nemeth Gyorgy <friczy@freemail.hu> - 2016-11-27 14:00 +0100
Re: How to get ssh to run in daemon script Russell Gadd <russ.mail.lists@gmail.com> - 2016-11-27 22:10 +0100
Re: How to get ssh to run in daemon script Richard Hector <richard@walnut.gen.nz> - 2016-11-28 13:30 +0100
Re: How to get ssh to run in daemon script Russell Gadd <russ.mail.lists@gmail.com> - 2016-11-28 22:30 +0100
csiph-web