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?
3 Answers
Follow the steps below:
Go to
File -> Settings -> Project Interpreterand add a new interpreterClick on
+to add a new python interpreter and then click onSSH interpreterProvide your
EC2 Public DNSin HOST andubuntuasusernameClick
Nextand add theprivate_key.pemfile.
See this article for more details: PyCharm setup for AWS automatic deployment
Comments
It looks like you can configure your python interpreter over SSH with the professional version of PyCharm.
Comments
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.
rootprivileges in automation. For almost everything that you can do as root, there's a better way to do it.