从一台计算机向另一台计算机发出Linux命令的最佳方法是什么? [英] What is the best way to give a Linux command from one machine to a different machine?

查看:76
本文介绍了从一台计算机向另一台计算机发出Linux命令的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的笔记本电脑上有一个Django项目.在我的机器上,它工作得很好.

此网络应用以图像的形式接收用户的输入,并读取其中的内容.如果内容已经存在于数据库中,它将在另一台计算机上运行Linux命令.两台机器都连接到同一网络.

当前,我正在使用SSH连接到另一台计算机,但是每次都要求输入密码.有什么方法可以消除我每次想运行命令时都不需要输入密码的需求?

解决方案

解决方案1:使用SSH预共享密钥通过SSH登录而无需输入密码.有关操作方法,请参见此链接它.正确配置它之后,便可以在服务器上运行命令:

  ssh主机名或raspi的ip命令arg1 arg2 ... 

,并且将在Raspberry PI上执行 command arg1 arg2 ... ,而不会提示您输入密码.

解决方案2:使用TCP通讯,并为Raspberry PI编写一个服务器,为您的服务器编写一个客户端.您可以使用原始套接字,也可以使用某些高级库,例如 zmq .

I have a Django project on my laptop. It works perfectly fine on my machine.

This web app takes input from the user in the form of an image and reads the content in it. If the content is already present on the database, it runs a Linux command on a different machine. Both machines are connected to the same network.

Currently, I am using SSH to connect to the other machine but it asks for password every time. Is there any way I can eliminate the need for entering a password every time I want to run a command?

解决方案

Solution 1: use SSH pre-shared key to login via SSH without a password. See this link for how to do it. After you have configured it properly, you are able to run a command on your server:

ssh hostname-or-ip-of-the-raspi command arg1 arg2 ...

and will execute command arg1 arg2 ... on the Raspberry PI, without being prompted for a password.

Solution 2: use TCP communication, and write a server for the Raspberry PI and a client for your server. You can use raw sockets, or some high level library such as zmq.

这篇关于从一台计算机向另一台计算机发出Linux命令的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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