ssh

Open SSH Tunnel with private key stored in S3

Open SSH Tunnel with private key stored in S3 Question: If I run the following code, my SSH Tunnel works perfectly. from sshtunnel import SSHTunnelForwarder tunnel = SSHTunnelForwarder( ssh_host=(SSH_JUMPHOST, SSH_PORT), ssh_username=SSH_USERNAME, ssh_pkey="/path/to/key/in/my/machine", remote_bind_address=( REMOTE_HOST, REMOTE_PORT, ), local_bind_address=("127.0.0.1", 12345), ssh_private_key_password=SSH_PKEY_PASSWORD, ) tunnel.start() # Things happen in the tunnel… However, I want to read a .pem key …

Total answers: 1

PubkeyAcceptedKeyTypes=+ssh-rsa with paramiko

PubkeyAcceptedKeyTypes=+ssh-rsa with paramiko Question: Is there a way to have the same behavior with paramiko, as when using -o PubkeyAcceptedKeyTypes=+ssh-rsa ssh option? Asked By: JenyaKh || Source Answers: Paramiko uses ssh-rsa by default. No need to enable it. But if you have problems with public keys, it might be because recent versions of Paramiko first …

Total answers: 1

Using python difflib to compare more than two files

Using python difflib to compare more than two files Question: I would like to get an overview over e.g. the ldd dependency list of multiple (3+) computers by comparing them with each other and highlighting the differences. For example, if I have a dict that looks as following: my_ldd_outputs = { 01:"<ldd_output>", 02:"<ldd_output>", … 09:"<ldd_output>", …

Total answers: 2

Connecting to Globalscape SFTP server with two-factor password and key authentication using Python Paramiko/pysftp

Connecting to Globalscape SFTP server with two-factor password and key authentication using Python Paramiko/pysftp Question: While working on a file upload project, using pysftp/paramiko I stumbled on an SFTP server connection issue: The SFTP server requires the following authentication flow: username + private key -> ‘welcome the sftp server’ -> password Using Linux sftp CLI …

Total answers: 2

Popen printing weird whitespace

Popen printing weird whitespace Question: I am trying to run ssh using subprocess.Popen. It works, but keeps printing some weird whitespace. As the time goes on, whitespace increases Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi Hi And my code was from subprocess import Popen, DEVNULL …

Total answers: 1

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

Cannot connect to MongoDB when tunneling SSH connection

Cannot connect to MongoDB when tunneling SSH connection Question: I am developing a GUI using Flask. I am running Ubuntu 20.04. The data that I need is from MongoDB, which is running on a Docker container on a server. My Mongo URI is "mongodb://<USERNAME>:<PASSWORD>@localhost:9999/<DB>?authSource=<AUTHDB>". First I tunnel the SSH connection to the server: ssh -L …

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