Skip to content

Instantly share code, notes, and snippets.

@klausbrunner
Created December 10, 2015 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klausbrunner/098ee76ddcb94f4a1ebe to your computer and use it in GitHub Desktop.
Save klausbrunner/098ee76ddcb94f4a1ebe to your computer and use it in GitHub Desktop.
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()
@leosx
Copy link

leosx commented Feb 1, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment