Having issues with remote command execution - ssh -t host 'sudo command'

Peter Stuge peter at stuge.se
Thu Feb 9 21:59:57 EST 2012

Merto Mertek wrote:
> spec:
> os: ubuntu 10.0, OpenSSH_5.5p1 Debian-4ubuntu4, OpenSSL 0.9.8o
> problem:
> When trying to restart deamons on remote pcs having the same specs,
> sometimes deamons are executed succesfully and sometimes not.

The problem happens when stdin, stdout and stderr are not all closed
by the daemon. This is very well known.

> I am using the following command:
> ssh -t -vvv "$host" 'sudo /usr/local/sbin/program'
> which asks me for a pass and then continues.

Instead you should let the ubuntu service manager (upstartd for now)
manage your services, and use the commands put in place by the
service manager for controlling your services.

Avoid starting things manually. Incidentally, if you do make your
services run under the service manager then you will also never have
the stdio problem.


More information about the openssh-unix-dev mailing list