Starting ssh-agent on Windows 10 fails: “unable to start ssh-agent service, error :1058”

Yeah, as others have suggested, this error seems to mean that ssh-agent is installed but its service (on windows) hasn’t been started. You can check this by running in Windows PowerShell: > Get-Service ssh-agent And then check the output of status is not running. Status Name DisplayName —— —- ———– Stopped ssh-agent OpenSSH Authentication Agent … Read more

SSH Agent Forwarding with Ansible

The problem is resolved by removing this line from the playbook: sudo: yes When sudo is run on the remote host, the environment variables set by ssh during login are no longer available. In particular, SSH_AUTH_SOCK, which “identifies the path of a UNIX-domain socket used to communicate with the agent” is no longer visible so … Read more

Authentication with PPK key in SSH.NET

SSH.NET does not support .ppk key files. You have to use PuTTYgen to convert the .ppk key to OpenSSH format. See How to convert SSH keypairs generated using PuTTYgen (Windows) into key-pairs used by ssh-agent and Keychain (Linux). Original answer, before the question was edited: You are using multifactor private key and keyboard interactive authentication … Read more

How to execute a script remotely in Python using SSH?

The code below will do what you want and you can adapt it to your execute function: from paramiko import SSHClient host=”hostname” user=”username” client = SSHClient() client.load_system_host_keys() client.connect(host, username=user) stdin, stdout, stderr = client.exec_command(‘./install.sh’) print “stderr: “, stderr.readlines() print “pwd: “, stdout.readlines() Note, though, that commands will default to your $HOME directory, so you’ll either … Read more

List files on SFTP server matching wildcard in Python using Paramiko

The glob will not magically start working with a remote server, just because you have instantiated SSHClient before. You have to use Paramiko API to list the files, like SFTPClient.listdir: import fnmatch sftp = client.open_sftp() for filename in sftp.listdir(‘/home/test’): if fnmatch.fnmatch(filename, “*.txt”): print filename You can also use a regular expression for the matching, if … Read more

make git clone with sudo

When you run git using sudo, git will run as root. Because git is running as root, ssh is running as root. Because ssh is running as root, it is trying to log on to the remote server as root. The remote server is not okay with this (as it should be!) You will need … Read more