Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郑天保
webssh
Commits
c9913a41
Commit
c9913a41
authored
Dec 08, 2017
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ECDSAKey and Ed25519Key for authentication
parent
9dda12eb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
8 deletions
+24
-8
main.py
main.py
+24
-8
No files found.
main.py
View file @
c9913a41
...
...
@@ -118,20 +118,36 @@ class Worker(object):
class
IndexHandler
(
tornado
.
web
.
RequestHandler
):
def
get_privatekey
(
self
):
try
:
return
self
.
request
.
files
.
get
(
'privatekey'
)[
0
][
'body'
]
data
=
self
.
request
.
files
.
get
(
'privatekey'
)[
0
][
'body'
]
except
TypeError
:
return
return
data
.
decode
(
'utf-8'
)
def
get_specific_pkey
(
self
,
pkeycls
,
privatekey
,
password
):
logging
.
info
(
'Trying {}'
.
format
(
pkeycls
.
__name__
))
try
:
pkey
=
pkeycls
.
from_private_key
(
io
.
StringIO
(
privatekey
),
password
=
password
)
except
paramiko
.
PasswordRequiredException
:
raise
ValueError
(
'Need password to decrypt the private key.'
)
except
paramiko
.
SSHException
:
pass
else
:
return
pkey
def
get_pkey
(
self
,
privatekey
,
password
):
if
not
password
:
password
=
None
password
=
password
.
encode
(
'utf-8'
)
if
password
else
None
spkey
=
io
.
StringIO
(
privatekey
.
decode
(
'utf-8'
))
pkey
=
self
.
get_specific_pkey
(
paramiko
.
RSAKey
,
privatekey
,
password
)
\
or
self
.
get_specific_pkey
(
paramiko
.
DSSKey
,
privatekey
,
password
)
\
or
self
.
get_specific_pkey
(
paramiko
.
ECDSAKey
,
privatekey
,
password
)
\
or
self
.
get_specific_pkey
(
paramiko
.
Ed25519Key
,
privatekey
,
password
)
if
not
pkey
:
raise
ValueError
(
'Wrong password for decrypting the private key'
' or the private key is not valid.'
)
try
:
pkey
=
paramiko
.
RSAKey
.
from_private_key
(
spkey
,
password
=
password
)
except
paramiko
.
SSHException
:
pkey
=
paramiko
.
DSSKey
.
from_private_key
(
spkey
,
password
=
password
)
return
pkey
def
get_port
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment