Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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