Accessing the gerrit SSH interface using Python (via ssh config entry)
#!/usr/bin/env python | |
import paramiko | |
import sys | |
import os | |
client = paramiko.SSHClient() | |
client.load_system_host_keys() | |
client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
config = paramiko.SSHConfig() | |
config.parse(open(os.path.expanduser('~/.ssh/config'))) | |
host = config.lookup('gerrit') # name of ssh config entry | |
client.connect(host['hostname'], username=host['user'], port=int(host['port']), key_filename=host['identityfile']) | |
stdin, stdout, stderr = client.exec_command('gerrit ls-projects') | |
print(stdout.readlines()) | |
client.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
In version of gerrit 2.16 ,will stop in line 15, don't response. how can i do???
my environment:
python version:3.7.1
paramiko version: 2.4.2