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
53ed3aef
Commit
53ed3aef
authored
Apr 10, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check is_missing_host_keys before adding them
parent
838d4533
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
main.py
main.py
+11
-0
No files found.
main.py
View file @
53ed3aef
...
...
@@ -40,8 +40,19 @@ class AutoAddPolicy(paramiko.client.MissingHostKeyPolicy):
"""
lock
=
threading
.
Lock
()
def
is_missing_host_keys
(
self
,
client
,
hostname
,
key
):
k
=
client
.
_host_keys
.
lookup
(
hostname
)
if
k
is
None
:
return
True
host_key
=
k
.
get
(
key
.
get_name
(),
None
)
if
host_key
is
None
:
return
True
if
host_key
!=
key
:
raise
paramiko
.
BadHostKeyException
(
hostname
,
key
,
host_key
)
def
missing_host_key
(
self
,
client
,
hostname
,
key
):
with
self
.
lock
:
if
self
.
is_missing_host_keys
(
client
,
hostname
,
key
):
keytype
=
key
.
get_name
()
logging
.
info
(
'Adding {} host key for {}'
.
format
(
keytype
,
hostname
)
...
...
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