Using PyCharm on a remote server - python

I never used a server before (only my local machine), and recently I was given a server with Python files on it. I was also given SSH key and a password.
I'm trying to connect PyCharm to the server from my local machine so that I can write code on my local machine, upload the code to the server, and use code from existing files on the server.
The only website I found is this, and I followed the instructions to create an SSH interpreter, but I'm not sure what to do next (in order to see the files, write files to the server, etc,).

Related

How to get files from remote windows server with python?

I have multiple windows servers in an internal network(meaning, not connected to the internet).
At the moment, I am pulling files from these servers using Windows Remote Desktop, for each server I have an IP address, login & password.
My goal is to use Python to automate this process, I want to be able to run a script that will access these internal servers and get files from them.
Is there any Python module that handles such tasks, or how should I approach this problem?
Windows' file sharing protocol is called SMB. There are some python libraries for this; the first google result for me was this one: https://pysmb.readthedocs.io/en/latest/

Run a script located on remote server using python

I have a python script located on a remote server with SSH enabled. That script displays a lot of debug messages displayed while executing. I want to trigger this script using another python script which is on my local system and depending on the output of the earlier script, I want to proceed further. While doing all this, I want the display messages on the remote server to be displayed on my local system as well. Basically, I want to view whatever output is thrown by the remote script during the course of the script, on my local system. I am able to trigger the script using paramiko but I am neither able to check whether the script on the remote server is running nor am I able to view it's output. Is there any way to do it? Already tried conn.recv(65535) but to no avail.
In my experience I found python fabric module easier than using paramiko. If you want to execute local script on remote machine using fabric. You just need to upload them using put() and then call run() api.
http://docs.fabfile.org/en/1.14/api/core/operations.html#fabric.operations.put

How to read excel file from remote server using python ubuntu

I have a local machine connected with internet.From my local machine i can access different machine or remote server.
On this remote server i have a excel/csv file.
I want to read this excel/csv file from my local machine using python programming.
How to read the excel/csv file located in different machine/remote server.
The pysftp package might help. Check out this writeup, which includes code examples of authenticating and fetching a file.

pycharm remote interpreter with two factor authentication

I would like to use PyCharm with a remote interpreter (in fact using the remote directory structure). The server I am connecting to has two factor authentication which requires a password and time changing code.
How do I setup a login so that PyCharm prompts me for the one time use code?
Will PyCharm use the remote directory structure as I would like or will it keep saving things locally?

Connected to ssh session via my browser. How can I access my local files through the browser?

I'm connected to a VM on a private network at address 'abc.def.com' using ssh, and on that VM there's an application that hosts a Python web app (IPython Notebook) that I can access by pointing my local browser to 'abc.def.com:7777'.
From that web app I can call shell commands by preceding them with '!', for example !ls -lt will list the files in the VM current working directory. But since I'm using my own laptop's browser, I think I should be able to run shell commands on my local files as well. How would I do that?
If that's not possible, what Python/shell command can I run from within the web app to automatically get my laptop's IP address to use things like scp? I know how to get my IP address, but I'd like to create a program that will automatically enable scp for whoever uses it.
You have ssh access so you could possibly write a python function that would let you transfer files via scp the secure copy command which uses ssh to communicate. If you exchange keys with the server you wouldn't have to put in a password so I see no problem from that standpoint. The issue is if you have an address for your local machine to be accessed from the server.
I work on various remotes from my laptop all day and from my laptop to the sever I could have this function:
def scp_to_server(address, local_file, remote_file):
subprocess.call(['scp',local_file,"myusername#{}:{}".format(address, remote_file)])
that would copy a file from my local machine to the remote provided the paths were correct, I have permissions to copy the files, and my local machine's id_rsa.pub key is in the ~/.ssh/authorized_keys file on the remote.
I have no way to initiate a secure copy from the remote to my local machine however because I don't have an address to access the local machine from that I can "see" on the remote.
If I open the terminal on my laptop and run hostname I see mylaptop.local and on the remote I see remoteserver#where.i.work.edu but the first is a local address I can see it from other machines on my LAN at home, (because I have configured that) but I can't see mylaptop.local from the remote. I know there is a way to configure that so I could find my laptop at home from anywhere, but I never had the need to do that (since I bring the laptop with me) so I can't help you there. I think there are a few more hurdels to go-over than you would like.
You could implement the function above on your local machine and transfer the files that way though.

Categories

Resources