Added a new field passphrase

pull/75/head
Sheng 2019-07-06 10:12:28 +08:00
parent bec5b605fb
commit c0eba0ebb3
3 changed files with 19 additions and 15 deletions

View File

@ -310,10 +310,10 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
self.lookup_hostname(hostname, port)
username = self.get_value('username')
password = self.get_argument('password', u'')
passphrase = self.get_argument('passphrase', u'')
privatekey, filename = self.get_privatekey()
if privatekey:
pkey = PrivateKey(privatekey, password, filename).get_pkey_obj()
password = None
pkey = PrivateKey(privatekey, passphrase, filename).get_pkey_obj()
else:
pkey = None
args = (hostname, port, username, password, pkey)
@ -336,7 +336,9 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
logging.info('Connecting to {}:{}'.format(*dst_addr))
try:
ssh.connect(*args, timeout=6)
ssh.connect(
*args, timeout=6, allow_agent=False, look_for_keys=False
)
except socket.error:
raise ValueError('Unable to connect to {}:{}'.format(*dst_addr))
except paramiko.BadAuthenticationType:

View File

@ -515,9 +515,9 @@ jQuery(function($){
}
function normalize_data(data) {
function clean_data(data) {
var i, attr, val;
var attrs = fields.concat('privatekey');
var attrs = fields.concat(['password', 'privatekey', 'passphrase']);
for (i = 0; i < attrs.length; i++) {
attr = attrs[i];
@ -530,7 +530,7 @@ jQuery(function($){
function validate_form_data(data) {
normalize_data(data);
clean_data(data);
var hostname = data.get('hostname'),
port = data.get('port'),
@ -668,7 +668,7 @@ jQuery(function($){
}
function connect(hostname, port, username, password, privatekey) {
function connect(hostname, port, username, password, privatekey, passphrase) {
// for console use
var result, opts;
@ -686,7 +686,8 @@ jQuery(function($){
port: port,
username: username,
password: password,
privatekey: privatekey
privatekey: privatekey,
passphrase: passphrase
};
} else {
opts = hostname;

View File

@ -9,7 +9,7 @@
<link href="static/css/fullscreen.min.css" rel="stylesheet" type="text/css"/>
<style>
.row {
margin-top: 20px;
margin-top: 15px;
margin-bottom: 10px;
}
@ -18,7 +18,7 @@
}
.btn {
margin-top: 10px;
margin-top: 15px;
}
.btn-danger {
@ -45,17 +45,18 @@
<input class="form-control" type="text" id="username" name="username" value="" required>
</div>
<div class="col">
<label for="Username">Private Key</label>
<input class="form-control" type="file" id="privatekey" name="privatekey" value="">
<label for="Password">Password</label>
<input class="form-control" type="password" name="password" value="">
</div>
</div>
<div class="row">
<div class="col">
<label for="Password">Password</label>
<input class="form-control" type="password" name="password" value="">
<label for="Username">Private Key</label>
<input class="form-control" type="file" id="privatekey" name="privatekey" value="">
</div>
<div class="col">
If Private Key is chosen, password will be used to decrypt the Private Key if it is encrypted, otherwise used as the password of username.
<label for="Passphrase">Passphrase</label>
<input class="form-control" type="password" name="passphrase" value="">
</div>
</div>
{% module xsrf_form_html() %}