[linux] linux execute command remotely

how do I execute command/script on a remote linux box? say I want to do service tomcat start on box b from box a.

This question is related to linux command

The answer is

I guess ssh is the best secured way for this, for example :

ssh -OPTIONS -p SSH_PORT [email protected]_server "remote_command1; remote_command2; remote_script.sh"  

where the OPTIONS have to be deployed according to your specific needs (for example, binding to ipv4 only) and your remote command could be starting your tomcat daemon.

If you do not want to be prompt at every ssh run, please also have a look to ssh-agent, and optionally to keychain if your system allows it. Key is... to understand the ssh keys exchange process. Please take a careful look to ssh_config (i.e. the ssh client config file) and sshd_config (i.e. the ssh server config file). Configuration filenames depend on your system, anyway you'll find them somewhere like /etc/sshd_config. Ideally, pls do not run ssh as root obviously but as a specific user on both sides, servers and client.

Some extra docs over the source project main pages :

ssh and ssh-agent
man ssh


an older tuto in French (by myself :-) but might be useful too :

Similar questions with linux tag:

Similar questions with command tag: