Revision 9a9af391 ncclient/transport/ssh.py
b/ncclient/transport/ssh.py | ||
---|---|---|
30 | 30 |
MSG_DELIM = ']]>]]>' |
31 | 31 |
TICK = 0.1 |
32 | 32 |
|
33 |
def default_unknown_host_cb(host, key):
|
|
33 |
def default_unknown_host_cb(host, fingerprint):
|
|
34 | 34 |
"""An `unknown host callback` returns :const:`True` if it finds the key |
35 | 35 |
acceptable, and :const:`False` if not. |
36 | 36 |
|
... | ... | |
40 | 40 |
Supply another valid callback if you need to verify the host key |
41 | 41 |
programatically. |
42 | 42 |
|
43 |
:arg host: the host for whom key needs to be verified
|
|
43 |
:arg host: the hostname that needs to be verified
|
|
44 | 44 |
:type host: string |
45 | 45 |
|
46 |
:arg key: a hex string representing the host key fingerprint
|
|
47 |
:type key: string
|
|
46 |
:arg fingerprint: a hex string representing the host key fingerprint
|
|
47 |
:type fingerprint: string
|
|
48 | 48 |
""" |
49 | 49 |
return False |
50 | 50 |
|
51 |
def _colonify(fp): |
|
52 |
finga = fp[:2] |
|
53 |
for idx in range(2, len(fp), 2): |
|
54 |
finga += ":" + fp[idx:idx+2] |
|
55 |
return finga |
|
51 | 56 |
|
52 | 57 |
class SSHSession(Session): |
53 | 58 |
|
... | ... | |
63 | 68 |
# parsing-related, see _parse() |
64 | 69 |
self._parsing_state = 0 |
65 | 70 |
self._parsing_pos = 0 |
66 |
|
|
71 |
|
|
67 | 72 |
def _parse(self): |
68 | 73 |
'''Messages ae delimited by MSG_DELIM. The buffer could have grown by a |
69 | 74 |
maximum of BUF_SIZE bytes everytime this method is called. Retains state |
... | ... | |
205 | 210 |
server_key = t.get_remote_server_key() |
206 | 211 |
known_host = self._host_keys.check(host, server_key) |
207 | 212 |
|
208 |
fingerprint = hexlify(server_key.get_fingerprint())
|
|
213 |
fingerprint = _colonify(hexlify(server_key.get_fingerprint()))
|
|
209 | 214 |
|
210 | 215 |
if not known_host and not unknown_host_cb(host, fingerprint): |
211 | 216 |
raise SSHUnknownHostError(host, fingerprint) |
... | ... | |
226 | 231 |
c.invoke_subsystem('netconf') |
227 | 232 |
|
228 | 233 |
self._post_connect() |
229 |
|
|
234 |
|
|
230 | 235 |
# on the lines of paramiko.SSHClient._auth() |
231 | 236 |
def _auth(self, username, password, key_filenames, allow_agent, |
232 | 237 |
look_for_keys): |
Also available in: Unified diff