Created
December 10, 2015 18:11
-
-
Save klausbrunner/098ee76ddcb94f4a1ebe to your computer and use it in GitHub Desktop.
Accessing the gerrit SSH interface using Python (via ssh config entry)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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
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