SSH remote execution

mgoellner
mgoellner used Ask the Experts™
on
Using SSH I want to do some remote execution from one Linux box on a couple of others. I have exported the SSH keys from the controlling machine which issues the remote commands to the target machines to avoid user/password authentication and using
ssh server "command" I can easily do what I want. However, some commands do not seem to return a returncode (or something) to the controlling machine's shell, the remote command does get executed remotely but the shell does not return. CTRlC returns the shell (Killed by signal 2.) but I'd need the command to simply finish running, as it were. Could anyone tell me if I can change this behavious somehow? I am aiming to run these commands via a script automatically n the background, not interactively.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2013
Top Expert 2013

Commented:
Hi,
which kind of command does not return?
Maybe you'll have to use -t or -tt for pseudo-terminal allocation, or -n to prevent ssh from reading stdin.
wmp

Author

Commented:
I am looking to remotely restart OpenVMPS, the first command stops the running VMPS server application via a simple kill, the second command restarts it again to reread the database. The actual commad is this:
ssh root@target "/usr/local/bin/vmpsd -l 1234 -f /vmps/vlan.db"

The actual restart is done via a PHP script which is accessed through a webserver. The script first writes a new file and then moves that file via SSH to the VMPS server, afterwards OpenVMPS needs to reread the file.

I added the -t switch, this does indeed return an interactive shell to me, unfortunately it does not do the same for the PHP script which seems to keep waiting for the command to finish its run.
Most Valuable Expert 2013
Top Expert 2013
Commented:
Try to force tty allocation using -tt
You can also force ssh into background using -f which might be useful in your php case.
Here is ssh's manpage -
http://unixhelp.ed.ac.uk/CGI/man-cgi?ssh+1
wmp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial