Skip to content

Commit fe315c9

Browse files
author
Pan
committed
Implemented public key subsystem.
Added public key list extension class for representing remote public key lists. Added public key attribute extension class for remote public key attributes.
1 parent bf2ebd0 commit fe315c9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ssh2/session.pyx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ from libc.time cimport time_t
2222

2323
cimport c_ssh2
2424
cimport c_sftp
25+
cimport c_pkey
2526
from agent cimport PyAgent, auth_identity, clear_agent
2627
from channel cimport PyChannel
2728
from exceptions cimport SessionHandshakeError, SessionStartupError, \
2829
AgentConnectionError, AgentListIdentitiesError, AgentGetIdentityError, \
2930
AuthenticationError
3031
from listener cimport PyListener
3132
from sftp cimport PySFTP
33+
from publickey cimport PyPublicKeySystem
3234
from utils cimport to_bytes, to_str
3335
IF EMBEDDED_LIB:
3436
from fileinfo cimport FileInfo
@@ -531,3 +533,12 @@ cdef class Session:
531533
self._session, _path, mode, size, mtime, atime)
532534
if channel is not NULL:
533535
return PyChannel(channel, self)
536+
537+
def publickey_init(self):
538+
"""Initialise public key subsystem for managing remote server
539+
public keys"""
540+
cdef c_pkey.LIBSSH2_PUBLICKEY *_pkey
541+
with nogil:
542+
_pkey= c_pkey.libssh2_publickey_init(self._session)
543+
if _pkey is not NULL:
544+
return PyPublicKeySystem(_pkey, self)

ssh2/sftp.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ ____________
5858

5959
from libc.stdlib cimport malloc, free
6060

61+
from session cimport Session
6162
cimport c_ssh2
6263
cimport c_sftp
6364
from error_codes cimport _LIBSSH2_ERROR_EAGAIN, _LIBSSH2_ERROR_BUFFER_TOO_SMALL
@@ -69,6 +70,7 @@ from sftp_handle cimport SFTPHandle, PySFTPHandle, SFTPAttributes, SFTPStatVFS
6970
# File types
7071
# TODO
7172

73+
7274
# File Transfer Flags
7375

7476
LIBSSH2_FXF_READ = c_sftp.LIBSSH2_FXF_READ
@@ -78,6 +80,7 @@ LIBSSH2_FXF_CREAT = c_sftp.LIBSSH2_FXF_CREAT
7880
LIBSSH2_FXF_TRUNC = c_sftp.LIBSSH2_FXF_TRUNC
7981
LIBSSH2_FXF_EXCL = c_sftp.LIBSSH2_FXF_EXCL
8082

83+
8184
# File mode masks
8285
# Read, write, execute/search by owner
8386
LIBSSH2_SFTP_S_IRWXU = c_sftp.LIBSSH2_SFTP_S_IRWXU

0 commit comments

Comments
 (0)