#!/usr/bin/env python import os, warnings with warnings.catch_warnings(): warnings.simplefilter("ignore") from paramiko.config import SSHConfig cfgdir = os.getenv("HOME")+"/.ssh" cfgfile = cfgdir+"/config" try: config_file = file(cfgfile) except IOError: if not os.path.exists(cfgdir): os.makedirs(cfgdir,0700) f = open(cfgfile,'w') o = '# SSH config file, \'man ssh_config\' for more details.\n\n' o += '#Host example\n' o += '# hostname example.com\n' o += '# user joebloggs\n' f.write(o) f.close() os.chmod(cfgfile, 0600) config_file = file(cfgfile) config = SSHConfig() config.parse(config_file) hosts = config._config else: config = SSHConfig() config.parse(config_file) hosts = config._config print '\n' if len(hosts) >= 2: for h in hosts[1:]: if h.has_key('host') and h.has_key('hostname'): user = '' if h.has_key('user'): user = '-l '+h['user']+ ' ' port = ['',''] if h.has_key('port'): port[0] = '-p '+h['port']+ ' ' port[1] = ':'+h['port'] print '' print ' ' print ' ' print ' ' print ' lxterminal -e "ssh '+user+port[0]+h['hostname']+'"' print ' ' print ' ' print ' \n' print ' ' print ' ' print ' ' print ' pcmanfm ssh://'+h['hostname']+port[1] print ' ' print ' ' print ' \n' print '\n' print '\n' print '' print ' ' print ' ' print ' geany ~/.ssh/config' print ' ' print ' ' print '\n' print ''