linux远程执行命令 [英] linux execute command remotely

查看:164
本文介绍了linux远程执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在远程Linux上执行命令/脚本?
说我想从框a中的框b上执行服务tomcat启动。

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.

推荐答案

是最安全的方式,例如:

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

ssh -OPTIONS -p SSH_PORT user@remote_server "remote_command1; remote_command2; remote_script.sh"  

其中OPTIONS必须根据您的特定需求例如,仅绑定到ipv4),您的远程命令可能会启动您的tomcat守护程序。

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.

注意:

如果您不想提示在每个ssh运行,也有一个看看ssh代理,并optionnaly到keychain如果你的系统允许它。密钥是...了解密钥交换过程。仔细查看ssh_config(例如ssh客户端配置)和sshd_config(例如ssh服务器配置)。配置文件名取决于您的系统,无论如何,你会在/ etc / sshd_config中找到它们。

Note:
if you do not want to be prompt at every ssh run, also have a look to ssh-agent, and optionnaly to keychain if your system allows it. Key is... to understand the keys exchange process. Take a careful look to ssh_config (eg ssh client config) and sshd_config (eg ssh server config). Config file names depends on your system, anyway you'll find them somewhere like /etc/sshd_config. Ideally do not run ssh as root obviously but with a dedicated user on both servers.

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

Some extra docs over the source project main pages :

ssh和ssh代理

man ssh(RMF!)

http://www.snailbook.com/index.html

https://help.ubuntu.com/community/SSH/OpenSSH/配置

http://sourceforge.net/apps/trac/sourceforge/wiki/SSH%20key%20fingerprints

ssh and ssh-agent
man ssh (RMF !)
http://www.snailbook.com/index.html
https://help.ubuntu.com/community/SSH/OpenSSH/Configuring
http://sourceforge.net/apps/trac/sourceforge/wiki/SSH%20key%20fingerprints

钥匙串

http://www.gentoo.org/doc/en/keychain-guide.xml

这篇关于linux远程执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆