linux远程执行命令

use*_*196 38 linux command

如何在远程linux机器上执行命令/脚本?说我想做一个服务tomcat从框a开始在框b上.

hor*_*bzz 54

我想这ssh是最好的安全方式,例如:

ssh -OPTIONS -p SSH_PORT user@remote_server "remote_command1; remote_command2; remote_script.sh"  
Run Code Online (Sandbox Code Playgroud)

必须根据您的特定需求部署OPTIONS(例如,仅绑定到ipv4),您的远程命令可以启动您的tomcat守护程序.

注意:
如果您不想在每次ssh运行时都提示,请同时查看ssh-agent,以及keychain您的系统是否允许它.关键是...了解ssh密钥交换过程.请仔细查看ssh_config(即ssh客户端配置文件)和sshd_config(即ssh服务器配置文件).配置文件名取决于你的系统,无论如何你会在某个地方找到它们/etc/sshd_config.理想情况下,pls不会以root身份运行ssh,而是作为双方,服务器和客户端的特定用户运行.

源项目主页上的一些额外文档:

ssh和ssh-agent
man ssh

http://www.snailbook.com/index.html
https://help.ubuntu.com/community/SSH/OpenSSH/Configuring

keychain
http://www.gentoo.org/doc/en/keychain-guide.xml
一个法语较旧的tuto(我自己:-)但也可能有用:http://hornetbzz.developpez.com/tutoriels/debian
/ SSH /钥匙扣/


Orb*_*bit 28

 ssh user@machine 'bash -s' < local_script.sh
Run Code Online (Sandbox Code Playgroud)

或者你可以

 ssh user@machine "remote command to run" 
Run Code Online (Sandbox Code Playgroud)