[英]How to run a python script on a remote ec2 instance using sudo from pycharm
I am running pycharm 2017.2.3. 我正在运行pycharm 2017.2.3。 I want to run my python script on a remote ec2 instance using sudo user through pycharm.
我想通过pycharm使用sudo用户在远程ec2实例上运行python脚本。 How do I acieve this?
我该如何处理?
Follow the steps below: 请按照以下步骤操作:
Go to File -> Settings -> Project Interpreter
and add a new interpreter 转到
File -> Settings -> Project Interpreter
然后添加一个新的解释器
Click on +
to add a new python interpreter and then click on SSH interpreter
单击
+
添加新的python解释器,然后单击SSH interpreter
Provide your EC2 Public DNS
in HOST and ubuntu
as username
在HOST和
ubuntu
提供EC2 Public DNS
作为username
Click Next
and add the private_key.pem
file. 单击“
Next
然后添加private_key.pem
文件。
See this article for more details: PyCharm setup for AWS automatic deployment 请参阅本文以了解更多详细信息: 用于AWS自动部署的PyCharm设置
It looks like you can configure your python interpreter over SSH with the professional version of PyCharm. 看起来您可以使用专业版PyCharm在SSH上配置python解释器。
Finally found an answer after a researching through the internet. 经过互联网的研究终于找到了答案。 We can have a script on remote machine as a pycharm interpreter.
我们可以在远程计算机上有一个脚本作为pycharm解释器。 Create a following script on a remote machine and make sure the script is executable.
在远程计算机上创建以下脚本,并确保该脚本可执行。
#!/bin/bash
sudo /usr/bin/python "$@"
Now change the project interpreter to point to the above script on remote machine in pycharm. 现在,将项目解释器更改为指向pycharm中远程计算机上的上述脚本。 Now every script you run on local machine gets executed on remote as a sudo user.
现在,您在本地计算机上运行的每个脚本都将以sudo用户的身份在远程执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.