ssh-rs ✨
Rust implementation of ssh2.0 client.
If you encounter any problems in use, welcome issues or PR .
Content
- ssh-rs ✨
- Content
- Connection method:
- Enable global logging:
- Set timeout:
- How to use:
- Algorithm support:
- 1. Kex algorithms
- 2. Server host key algorithms
- 3. Encryption algorithms (client to server)
- 4. Encryption algorithms (server to client)
- 5. Mac algorithms (client to server)
- 6. Mac algorithms (server to client)
- 7. Compression algorithms (client to server)
- 8. Compression algorithms (server to client)
- ☃️ Additional algorithms will continue to be added.
Connection method:
1. Password:
use ssh;
let mut session = create_session
.username
.password
.connect
.unwrap;
2. Public key:
- Currently, only RSA, ED25519 keys/key files are supported.
1. Use key file path:
// pem format key path -> /xxx/xxx/id_rsa
// the content of the keyfile shall begin with
// -----BEGIN RSA PRIVATE KEY----- / -----BEGIN OPENSSH PRIVATE KEY-----
// and end with
// -----END RSA PRIVATE KEY----- / -----END OPENSSH PRIVATE KEY-----
// simply generated by `ssh-keygen -t rsa -m PEM -b 4096`
use ssh;
let mut session = create_session
.username
.private_key_path
.connect
.unwrap;
2. Use key string:
// pem format key string:
// -----BEGIN RSA PRIVATE KEY----- / -----BEGIN OPENSSH PRIVATE KEY-----
// and end with
// -----END RSA PRIVATE KEY----- / -----END OPENSSH PRIVATE KEY-----
use ssh;
let mut session = create_session
.username
.private_key
.connect
.unwrap;
3. Use them together
- According to the implementation of OpenSSH, it will try public key first and fallback to password. So both of them can be provided.
use ssh;
let mut session = create_session
.username
.password
.private_key_path
.connect
.unwrap;
Enable global logging:
-
There are two APIs to enable logs, basicly
enable_log()
will set the log level toINFO
, anddebug()
will set it toDebug
-
But you can implement your own logger as well.
use ssh;
// this will generate some basic event logs
enable_log;
// this will generate verbose logs
debug
Set timeout:
- Only global timeouts per r/w are currently supported.
use ssh;
debug;
let _listener = bind.unwrap;
match create_session
.username
.password
.private_key_path
.timeout
.connect
How to use:
- Examples can be found under examples
- Execute a command
- Scp files
- Run a shell
- Run an interactive shell
- Connect ssh server w/o a tcp stream
- Cofigure your own algorithm list
Algorithm support:
1. Kex algorithms
curve25519-sha256
ecdh-sha2-nistp256
diffie-hellman-group14-sha256
diffie-hellman-group14-sha1
diffie-hellman-group1-sha1
(behind feature "dangerous-dh-group1-sha1")
2. Server host key algorithms
ssh-ed25519
rsa-sha2-256
rsa-sha2-512
rsa-sha
(behind feature "dangerous-rsa-sha1")
3. Encryption algorithms (client to server)
chacha20-poly1305@openssh.com
aes128-ctr
4. Encryption algorithms (server to client)
chacha20-poly1305@openssh.com
aes128-ctr
5. Mac algorithms (client to server)
hmac-sha2-256
hmac-sha2-512
hmac-sha1
6. Mac algorithms (server to client)
hmac-sha2-256
hmac-sha2-512
hmac-sha1
7. Compression algorithms (client to server)
none
8. Compression algorithms (server to client)
none