ssh

How to send HTTP GET request from remote host using SSH connection in Python?

How to send HTTP GET request from remote host using SSH connection in Python? Question: I’m using an SSH connection with Paramiko. My code: client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname=remote_host, username=remote_user, password=remote_password, port=remote_port) How to send HTTP GET request from connected remote host (use it like a proxy)? I’ve found solution according to the answer: with …

Total answers: 1

pip install package from private github repo with deploy key in docker

pip install package from private github repo with deploy key in docker Question: I’m trying to build a Docker container that should install a series of python packages from a requirements.txt file. One of the entries is a python package hosted on a private GitHub repository. To install it, I’ve created a pair of SSH …

Total answers: 1

A command does not finish when executed using Python Paramiko exec_command

A command does not finish when executed using Python Paramiko exec_command Question: I’ve got a Python program which sits on a remote server which uploads a file to an AWS bucket when run. If I ssh onto the server and run it with the command sudo python3 /path/to/backup.py it works as expected. I’m writing a …

Total answers: 1

Paramiko ValueError "p must be exactly 1024, 2048, or 3072 bits long"

Paramiko ValueError "p must be exactly 1024, 2048, or 3072 bits long" Question: I am trying to connect SFTP using Python script. I’m unable to connect due to “p error”. import paramiko client = paramiko.SSHClient() client.load_system_host_keys() client.connect(‘####.com’, username=’####’, password=’###’) stdin, stdout, stderr = client.exec_command(‘ls -l’) Error: ValueError: p must be exactly 1024, 2048, or 3072 …

Total answers: 1

Reading file opened with Python Paramiko SFTPClient.open method is slow

Reading file opened with Python Paramiko SFTPClient.open method is slow Question: I am trying to remote read a netcdf file. I used Paramiko package to read my file, like this: import paramiko from netCDF4 import Dataset client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(hostname=’hostname’, username=’usrname’, password=’mypassword’) sftp_client = client.open_sftp() ncfile = sftp_client.open(‘mynetCDFfile’) b_ncfile = ncfile.read() # **** nc …

Total answers: 1

Open a Matplotlib figure through SSH tunnel of vscode

Open a Matplotlib figure through SSH tunnel of vscode Question: I am setting up a remote workstation to run machine learning related python code from my laptop on another computer that includes a GPU. I use the SSH remote feature of vscode to remotely run and debug my code and I am very happy with …

Total answers: 6

tkinter.TclError: no display name and no $DISPLAY environment variable python

tkinter.TclError: no display name and no $DISPLAY environment variable python Question: I want to execute my python file in a remote system using ssh. I exported the file to the remote system. Here’s the sample file: import os import time import pymsgbox pymsgbox.alert(‘Hi Afreeth ‘, ‘Welcome’) if ‘DISPLAY’ not in os.environ: pass I want to …

Total answers: 2

What is the difference between exec_command and send with invoke_shell() on Paramiko?

What is the difference between exec_command and send with invoke_shell() on Paramiko? Question: So what is the difference between SSHClient.exec_command() and send with SSHClient.invoke_shell on Paramiko? I can send and execute command with exec_command to MikroTik router device but can’t execute it with send (invoke_shell()). On the other hand, I can send and execute command …

Total answers: 1

Paramiko: "not a valid RSA private key file"

Paramiko: "not a valid RSA private key file" Question: I am trying connect to server using following spinet ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ip = [‘x.x.x.x’] key_file = “/Users/user/.ssh/id_rsa” key = paramiko.RSAKey.from_private_key_file(key_file) ssh.load_system_host_keys() ssh.connect(ips, port=22, username=’XYZ’, pkey=key, timeout=11) But I am getting an error: not a valid RSA private key file Asked By: Owais Ahmad || …

Total answers: 6