1
+ import base64
1
2
import random
2
3
import socket
3
4
# import sys
6
7
import paramiko
7
8
8
9
from binascii import hexlify
9
- from paramiko .py3compat import u , decodebytes
10
10
from tests .utils import make_tests_data_path
11
11
12
12
16
16
host_key = paramiko .RSAKey (filename = make_tests_data_path ('test_rsa.key' ))
17
17
# host_key = paramiko.DSSKey(filename='test_dss.key')
18
18
19
- print ('Read key: ' + u ( hexlify (host_key .get_fingerprint ())))
19
+ print ('Read key: ' + hexlify (host_key .get_fingerprint ()). decode ( 'utf-8' ))
20
20
21
21
banner = u'\r \n \u6b22 \u8fce \r \n '
22
22
event_timeout = 5
@@ -29,7 +29,7 @@ class Server(paramiko.ServerInterface):
29
29
b'fAu7jJ2d7eothvfeuoRFtJwhUmZDluRdFyhFY/hFAh76PJKGAusIqIQKlkJxMC'
30
30
b'KDqIexkgHAfID/6mqvmnSJf0b5W8v5h2pI/stOSwTQ+pxVhwJ9ctYDhRSlF0iT'
31
31
b'UWT10hcuO4Ks8=' )
32
- good_pub_key = paramiko .RSAKey (data = decodebytes (data ))
32
+ good_pub_key = paramiko .RSAKey (data = base64 . decodebytes (data ))
33
33
34
34
commands = [
35
35
b'$SHELL -ilc "locale charmap"' ,
@@ -62,7 +62,7 @@ def check_auth_password(self, username, password):
62
62
return paramiko .AUTH_FAILED
63
63
64
64
def check_auth_publickey (self , username , key ):
65
- print ('Auth attempt with username: {!r} & key: {!r}' .format (username , u ( hexlify (key .get_fingerprint ())))) # noqa
65
+ print ('Auth attempt with username: {!r} & key: {!r}' .format (username , hexlify (key .get_fingerprint ()). decode ( 'utf-8' ))) # noqa
66
66
if (username in ['robey' , 'keyonly' ]) and (key == self .good_pub_key ):
67
67
return paramiko .AUTH_SUCCESSFUL
68
68
if username == 'pkey2fa' and key == self .good_pub_key :
0 commit comments