-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
21 changed files
with
4,801 additions
and
6,434 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ local | |
libssh/compile_commands.json | ||
wheelhouse | ||
.idea | ||
tests/unit_test_cert_key-cert.pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.