Merto Mertek
2012-Feb-08 23:11 UTC
Having issues with remote command execution - ssh -t host 'sudo command'
I've been trying to find an answer on other sites however I could not resolve my problem. 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. I am using the following command: ssh -t -vvv "$host" 'sudo /usr/local/sbin/program' which asks me for a pass and then continues. From the debug log I can see that the difference from a successfull and unsuscesful run depends on sequence of the following code blocks. If successful first runs code block1 and then block2, otherwise the opposite. code1: debug2: channel 0: rcvd eof debug2: channel 0: output open -> drain debug2: channel 0: obuf empty debug2: channel 0: close_write debug2: channel 0: output drain -> closed code2: debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: client_input_channel_req: channel 0 rtype eow at openssh.com reply 0 debug2: channel 0: rcvd eow debug2: channel 0: close_read debug2: channel 0: input open -> closed Any help appreciated.. thanks
Peter Stuge
2012-Feb-09 10:59 UTC
Having issues with remote command execution - ssh -t host 'sudo command'
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. //Peter