[英]Remote server command execute
What would be the best way to execute shell commands on remote servers and get output without actually logging in. 什么是在远程服务器上执行shell命令并获得输出而不实际登录的最佳方法。
Maybe with shh keys. 也许用shh键。 Preferably with python.
最好用python。
You mean without logging in manually ? 你的意思是没有手动登录? Because a server that actually let you execute commands without logging in at all would be a humongous security risk.
因为实际上允许您在不登录的情况下执行命令的服务器将是一个巨大的安全风险。
It looks like in the area of Python interfaces to SSH, Paramiko is what everybody's using these days. 看起来在SSH的Python接口领域,Paramiko是现在每个人都在使用的东西。 Here's a nice introductory article I found through Google: http://jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/
这是我通过Google找到的一篇很好的介绍性文章: http : //jessenoller.com/2009/02/05/ssh-programming-with-paramiko-completely-different/
In order to avoid entering a password every time you log in, you would indeed want to set up an SSH key pair on your computer and send the public key to the server. 为了避免每次登录时都输入密码,您确实需要在计算机上设置SSH密钥对并将公钥发送到服务器。 The method of doing so depends on what SSH client you use and what SSH server software the server uses.
这样做的方法取决于您使用的SSH客户端以及服务器使用的SSH服务器软件。
Paramiko is really good and convenient for transferring files and executing commands in remote server. Paramiko非常适合在远程服务器中传输文件和执行命令。
But, the problem is that we won't be able to catch the output of the command. 但是,问题是我们无法捕获命令的输出 。 It will be difficult to understand whether the command executed properly or not.
很难理解命令是否正确执行。
Paramico is the most convenient way to use SSH with Python that I've found so far. 到目前为止,Paramico是使用SSH和Python的最方便的方法。
Good luck! 祝好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.