简体   繁体   English

远程服务器命令执行

[英]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服务器软件。

I'm assuming you want to streamline your usage of SSH for application deployment or systems administration tasks. 我假设您希望简化您对应用程序部署或系统管理任务的SSH使用。

In that case I suggest Fabric . 在那种情况下,我建议Fabric

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.

相关问题 用 Python 在远程机器上执行命令 - Execute a command on Remote Machine in Python Python执行ssh命令(仅用于远程端口转发的SSH服务器)并捕获输出 - Python execute ssh command(SSH server just for remote port forwarding) and capture the output 使用paramiko在远程机器上执行git命令 - execute git command in a remote machine using paramiko 从远程计算机在Docker容器上执行命令 - Execute command on docker container from remote machine 如何使用 python 脚本将 ssh 连接到远程 linux 服务器,并能够在 python 脚本中使用 ssh 时作为指定用户执行命令 - How to ssh to a remote linux server using python script and be able to execute command as the user specified while using ssh in the python script Python子进程执行远程服务器命令 - Python subprocess to execute remote server commands Python使用服务器资源执行远程应用程序 - Python execute remote application using server resource Putty(plink)-在远程Linux服务器上执行Python - Putty (plink) - Execute Python on remote Linux server 使用 Paramiko 从远程服务器执行命令到另一个远程服务器 - Executing command from remote server into another remote server using Paramiko 在一行中使用telnet在远程计算机上执行命令 - Execute a command on remote machine using telnet in a single line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM