Changeset 7657:f3dd54249626
- Timestamp:
- 11/11/07 17:00:08 (6 years ago)
- Branch:
- default
- File:
-
- 1 edited
-
sage/dsage/scripts/dsage_setup.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/dsage/scripts/dsage_setup.py
r6720 r7657 56 56 return config 57 57 58 def add_default_user(): 59 """ 60 Adds the default user. 61 62 """ 63 64 from twisted.conch.ssh import keys 65 import base64 66 from getpass import getuser 67 68 username = getuser() 69 pubkey_file = os.path.join(DSAGE_DIR, 'dsage_key.pub') 70 clientdb = ClientDatabase() 71 pubkey = base64.encodestring( 72 keys.getPublicKeyString(filename=pubkey_file).strip()) 73 if clientdb.get_user(username) is None: 74 clientdb.add_user(username, pubkey) 75 print 'Added user %s.\n' % (username) 76 else: 77 user, key = clientdb.get_user_and_key(username) 78 if key != pubkey: 79 clientdb.del_user(username) 80 clientdb.add_user(username, pubkey) 81 print "User %s's pubkey changed, setting to new one." % (username) 82 else: 83 print 'User %s already exists.' % (username) 84 58 85 def setup_client(testing=False): 59 86 check_dsage_dir() … … 62 89 cmd = ["ssh-keygen", "-q", "-trsa", "-P ''", "-f%s" % key_file] 63 90 return 64 91 92 if not cmd_exists('ssh-keygen'): 93 print DELIMITER 94 print "Could NOT find ssh-keygen." 95 print "Aborting." 96 return 97 65 98 print DELIMITER 66 99 print "Generating public/private key pair for authentication..." … … 68 101 print "Just hit enter when prompted for a passphrase" 69 102 print DELIMITER 103 70 104 cmd = ["ssh-keygen", "-q", "-trsa", "-f%s" % key_file] 71 105 ld = os.environ['LD_LIBRARY_PATH'] … … 75 109 finally: 76 110 os.environ['LD_LIBRARY_PATH'] = ld 111 77 112 print "\n" 78 113 print "Client configuration finished.\n" … … 131 166 f.write(s) 132 167 f.close() 168 133 169 # Disable certificate generation -- not used right now anyways 134 170 privkey_file = os.path.join(DSAGE_DIR, 'cacert.pem') 135 171 pubkey_file = os.path.join(DSAGE_DIR, 'pubcert.pem') 172 136 173 print DELIMITER 137 174 print "Generating SSL certificate for server..." 175 138 176 if os.uname()[0] != 'Darwin' and cmd_exists('openssl'): 139 177 # We use openssl by default if it exists, since it is *vastly* … … 157 195 subprocess.call(cmd, shell=True) 158 196 print DELIMITER 197 198 # Set read only permissions on cert 159 199 os.chmod(os.path.join(DSAGE_DIR, 'cacert.pem'), 0600) 160 200 161 # conf_file = os.path.join(DSAGE_DIR, 'server.conf')162 # config.write(open(conf_file, 'w'))163 164 201 # add default user 165 from twisted.conch.ssh import keys 166 import base64 167 168 # c = ConfigParser.ConfigParser() 169 # c.read(os.path.join(DSAGE_DIR, 'client.conf')) 170 from getpass import getuser 171 username = getuser() 172 pubkey_file = os.path.join(DSAGE_DIR, 'dsage_key.pub') 173 clientdb = ClientDatabase() 174 pubkey = base64.encodestring( 175 keys.getPublicKeyString(filename=pubkey_file).strip()) 176 if clientdb.get_user(username) is None: 177 clientdb.add_user(username, pubkey) 178 print 'Added user %s.\n' % (username) 179 else: 180 user, key = clientdb.get_user_and_key(username) 181 if key != pubkey: 182 clientdb.del_user(username) 183 clientdb.add_user(username, pubkey) 184 print "User %s's pubkey changed, setting to new one." % (username) 185 else: 186 print 'User %s already exists.' % (username) 202 add_default_user() 187 203 188 204 print "Server configuration finished.\n\n"
Note: See TracChangeset
for help on using the changeset viewer.
