Skip to content

Commit

Permalink
Certs (#31)
Browse files Browse the repository at this point in the history
* Added certificate key types and certificate authentication functions
* Added cert signing to embedded openssh server, CA host and user keys and certificate authentication tests
* Added exec example
  • Loading branch information
pkittenis authored Oct 21, 2020
1 parent eaa6587 commit 69d4a51
Show file tree
Hide file tree
Showing 21 changed files with 4,801 additions and 6,434 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ local
libssh/compile_commands.json
wheelhouse
.idea
tests/unit_test_cert_key-cert.pub
33 changes: 33 additions & 0 deletions examples/exec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import pwd
import socket

from ssh.session import Session
from ssh import options

# Linux only
USERNAME = pwd.getpwuid(os.geteuid()).pw_name
HOST = 'localhost'
PORT = 22

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))

s = Session()
s.options_set(options.HOST, HOST)
s.options_set(options.USER, USERNAME)
s.options_set_port(PORT)
s.set_socket(sock)
s.connect()

# Authenticate with agent
s.userauth_agent(USERNAME)

chan = s.channel_new()
chan.open_session()
chan.request_exec('echo me')
size, data = chan.read()
while size > 0:
print(data.strip())
size, data = chan.read()
chan.close()
15 changes: 14 additions & 1 deletion ssh/c_ssh.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,14 @@ cdef extern from "libssh/libssh.h" nogil:
SSH_KEYTYPE_ECDSA,
SSH_KEYTYPE_ED25519,
SSH_KEYTYPE_DSS_CERT01,
SSH_KEYTYPE_RSA_CERT01
SSH_KEYTYPE_RSA_CERT01,
SSH_KEYTYPE_ECDSA_P256,
SSH_KEYTYPE_ECDSA_P384,
SSH_KEYTYPE_ECDSA_P521,
SSH_KEYTYPE_ECDSA_P256_CERT01,
SSH_KEYTYPE_ECDSA_P384_CERT01,
SSH_KEYTYPE_ECDSA_P521_CERT01,
SSH_KEYTYPE_ED25519_CERT01
enum ssh_keycmp_e:
SSH_KEY_CMP_PUBLIC,
SSH_KEY_CMP_PRIVATE
Expand Down Expand Up @@ -452,6 +459,12 @@ cdef extern from "libssh/libssh.h" nogil:

const char *ssh_pki_key_ecdsa_name(const ssh_key key)

char *ssh_get_fingerprint_hash(ssh_publickey_hash_type type,
unsigned char *hash,
size_t len)
void ssh_print_hash(ssh_publickey_hash_type type,
unsigned char *hash,
size_t len)
void ssh_print_hexa(
const char *descr, const unsigned char *what, size_t len)
int ssh_send_ignore(ssh_session session, const char *data)
Expand Down
Loading

0 comments on commit 69d4a51

Please sign in to comment.