paramiko

paramiko – error with a large wget command

paramiko – error with a large wget command Question: this is my code: import paramiko import time host = "123.456.789" username = "myusername" password = "mypassword" client = paramiko.client.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(host, username=username, password=password) _stdin, _stdout,_stderr = client.exec_command("sudo -i") _stdin.write(password + ‘n’) _stdin, _stdout,_stderr = client.exec_command("sudo wget -O- ‘https://abc.com.gz’ | gunzip | dd of=/dev/sda", get_pty=True) _stdin.flush() …

Total answers: 1

Why read_excel() can't read xlsx from sftp server?

Why read_excel() can't read xlsx from sftp server? Question: When I try to read CSV from sftp server with read_csv() there is no problem at all. But when I try to read xlsx with read_excel() it never finishes reading file. I tried downloading from sftp and reading xlsx. It works well. But I didn’t understand …

Total answers: 1

How to generate a table with paramiko output using pandas

How to generate a table from arp command output using pandas Question: I have a arp command output executed with Paramiko in a table format as shown below: stdin, stdout, stderr = client.exec_command("arp") opt = stdout.read().decode(‘ascii’) print(opt) Address HWtype HWaddress Flags Mask Iface(Ports) 0.00.00.00 ether (incomplete) C eth0.1 0.00.00.00 ether (incomplete) C eth0.2 0.00.00.00 ether …

Total answers: 2

Automate `lxc-attach` through ssh with Python

Automate `lxc-attach` through ssh with Python Question: Question: How do I automate this process, and include all of the password prompts? Machine 1> ssh user2@machine2 password: Machine 2> lxc-attach -n 0x1000 Container> ssh user3@machine3 password: Machine 3> get_temperature.sh temperature is 65C Background: I am running some automated scripts on a computer (Machine 1) with several …

Total answers: 1

How to get back raw binary output from python fabric remote command?

How to get back raw binary output from python fabric remote command? Question: I am using Python 3.8.10 and fabric 2.7.0. I have a Connection to a remote host. I am executing a command such as follows: resObj = connection.run("cat /usr/bin/binaryFile") So in theory the bytes of /usr/bin/binaryFile are getting pumped into stdout but I …

Total answers: 1

Connecting to port 21 with Paramiko and got paramiko.ssh_exception.SSHException: Error reading SSH protocol banner

Connecting to port 21 with Paramiko and got paramiko.ssh_exception.SSHException: Error reading SSH protocol banner Question: I’m trying to connect to am SFTP server through Paramiko. I don’t have a host key. The following code is my attempt and it’s giving me an error that says: paramiko.ssh_exception.SSHException: Error reading SSH protocol banner I notice that port …

Total answers: 1

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log)

Paramiko authentication fails with "Agreed upon 'rsa-sha2-512' pubkey algorithm" (and "unsupported public key algorithm: rsa-sha2-512" in sshd log) Question: I have a Python 3 application running on CentOS Linux 7.7 executing SSH commands against remote hosts. It works properly but today I encountered an odd error executing a command against a "new" remote server (server …

Total answers: 5

Reading command output with Paramiko invoke_shell/send/recv never finishes

Reading command output with Paramiko invoke_shell/send/recv never finishes Question: I am trying to use send/recv function in Paramiko. According to what I see, the line throws an exception of timeout Evaluating: self.shell.recv(1024) did not finish after 3.00 seconds. tmp = shell.recv(1024) What is wrong with the function implementation? My exit condition from while True is …

Total answers: 1

Paramiko can't find keys from ssh-agent on Windows

Paramiko can't find keys from ssh-agent on Windows Question: I am trying to connect to a test device on my local network using paramiko and SSH. If I specify the filename of my key and its passphrase, I can connect to the device without a problem. However, since my script is meant to run on …

Total answers: 1