0

I am running pycharm 2017.2.3. I want to run my python script on a remote ec2 instance using sudo user through pycharm. How do I acieve this?

1
  • It's highly unlikely that you actually want to use root privileges in automation. For almost everything that you can do as root, there's a better way to do it. Commented Sep 16, 2017 at 3:30

3 Answers 3

2

Follow the steps below:

  1. Go to File -> Settings -> Project Interpreter and add a new interpreter

  2. Click on + to add a new python interpreter and then click on SSH interpreter

  3. Provide your EC2 Public DNS in HOST and ubuntu as username

  4. Click Next and add the private_key.pem file.

See this article for more details: PyCharm setup for AWS automatic deployment

Sign up to request clarification or add additional context in comments.

Comments

0

It looks like you can configure your python interpreter over SSH with the professional version of PyCharm.

Configuring Remote Interpreter + PyCharm

Comments

0

Finally found an answer after a researching through the internet. We can have a script on remote machine as a pycharm interpreter. 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. Now every script you run on local machine gets executed on remote as a sudo user.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.