~doctormo/groundcontrol/translations

« back to all changes in this revision

Viewing changes to GroundControl/sshkeys.py

  • Committer: Andrew Starr-Bochicchio
  • Date: 2010-01-30 04:27:50 UTC
  • mto: This revision was merged to the branch mainline in revision 128.
  • Revision ID: a.starr.b@gmail.com-20100130042750-8n0gwen7f1xvdati
Initial work on illn support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import commands
25
25
import glob
26
26
 
 
27
import locale
 
28
locale.setlocale(locale.LC_ALL, '')
 
29
import gettext
 
30
gettext.install("groundcontrol")
 
31
 
 
32
 
27
33
SSH_DIR = os.path.expanduser('~/.ssh/')
28
34
KNOWN_HOSTS = os.path.join(SSH_DIR, 'known_hosts')
29
35
 
46
52
def generate_key_file(tag):
47
53
    """Generates a filename in the .ssh directory"""
48
54
    filename = os.path.join(SSH_DIR, "%s_id_rsa" % tag)
49
 
    logging.debug("Making new ssh filename: %s" % filename)
 
55
    logging.debug(_("Making new ssh filename: %s") % filename)
50
56
    return filename
51
57
 
52
58
def generate_key(filename, password, comment=None):
53
59
    """Generate a new ssh key (rsa by default)"""
54
 
    logging.debug("Creating keygen ssh command")
 
60
    logging.debug(_("Creating keygen ssh command"))
55
61
    com = "ssh-keygen -t rsa -N '%s' -f '%s' -C '%s' -q" % (
56
62
        password, filename, comment)
57
63
    logging.debug(com)
58
64
    res = commands.getoutput(com)
59
 
    logging.debug("Keys hopefully generated!")
 
65
    logging.debug(_("Keys hopefully generated!"))
60
66
    return os.path.exists(filename)
61
67
 
62
68
def add_server_key(server):
69
75
        fh.close()
70
76
        part = fp.split(' ')[-1]
71
77
        if part in cont:
72
 
            logging.debug("Server '%s' already known." % server)
 
78
            logging.debug(_("Server '%s' already known.") % server)
73
79
            return
74
80
    elif not os.path.exists(SSH_DIR):
75
81
        os.mkdir(SSH_DIR)
76
 
    logging.debug("Server '%s' is unknown, adding to known_hosts." % server)
 
82
    logging.debug(_("Server '%s' is unknown, adding to known_hosts.") % server)
77
83
    fh = open(KNOWN_HOSTS, 'a')
78
84
    fh.write(fp+'\n')
79
85
    fh.close()