Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Run python script from windows to access data server via ssh

I am currently working from home, and I have a python script on my laptop that I would like to run, that has to access data from a remote server, that I can access via ssh. Is there a way to do this?

I cannot copy my script onto the server unfourtunately, because there is no disk space on there right now.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I think you should be able to open an SSH connection with paramiko.

import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('serveraddress', username='you', password='pass')

# DO python stuff here
# When you need a csv data - example SFTP
# sftp = ssh.open_sftp()
# fpath= '/path/to/data.csv'
# remote_file = sftp.open(fpath)
# import pandas as pd
# df = pd.read_csv(remote_file)

remote_file.close()
sftp.close()
ssh.close()
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading