Rust implementation of ssh2.0 client 👻 rust实现的ssh2.0客户端
See the codeRust implementation of ssh2.0 client.
If you encounter any problems in use, welcome issues or PR .
use ssh;
let mut session = ssh::create_session()
.username("ubuntu")
.password("password")
.connect("127.0.0.1:22")
.unwrap();
// 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 = ssh::create_session()
.username("ubuntu")
.private_key_path("./id_rsa")
.connect("127.0.0.1:22")
.unwrap();
// 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 = ssh::create_session()
.username("ubuntu")
.private_key("rsa_string")
.connect("127.0.0.1:22")
.unwrap();
use ssh;
let mut session = ssh::create_session()
.username("username")
.password("password")
.private_key_path("/path/to/rsa")
.connect("127.0.0.1:22")
.unwrap();
log compatible tracing for logging functionalityuse tracing::Level;
use tracing_subscriber::FmtSubscriber;
// this will generate some basic event logs
// a builder for `FmtSubscriber`.
let subscriber = FmtSubscriber::builder()
// all spans/events with a level higher than INFO (e.g, info, warn, etc.)
// will be written to stdout.
.with_max_level(Level::INFO)
// completes the builder.
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
use ssh;
let _listener = TcpListener::bind("127.0.0.1:7777").unwrap();
match ssh::create_session()
.username("ubuntu")
.password("password")
.private_key_path("./id_rsa")
.timeout(Some(std::time::Duration::from_secs(5)))
.connect("127.0.0.1:7777")
{
Err(e) => println!("Got error {}", e),
_ => unreachable!(),
}
curve25519-sha256ecdh-sha2-nistp256diffie-hellman-group14-sha256diffie-hellman-group14-sha1diffie-hellman-group1-sha1 (behind feature "deprecated-dh-group1-sha1")ssh-ed25519rsa-sha2-256rsa-sha2-512rsa-sha (behind feature "deprecated-rsa-sha1")ssh-dss (behind feature "deprecated-dss-sha1")chacha20-poly1305@openssh.comaes128-ctraes192-ctraes256-ctraes128-cbc (behind feature "deprecated-aes-cbc")aes192-cbc (behind feature "deprecated-aes-cbc")aes256-cbc (behind feature "deprecated-aes-cbc")3des-cbc (behind feature "deprecated-des-cbc")hmac-sha2-256hmac-sha2-512hmac-sha1nonezlib@openssh.comzlib (behind feature "zlib")Rust
99.7%
Rust implementation of ssh2.0 client 👻 rust实现的ssh2.0客户端
See the codeRust implementation of ssh2.0 client.
If you encounter any problems in use, welcome issues or PR .
use ssh;
let mut session = ssh::create_session()
.username("ubuntu")
.password("password")
.connect("127.0.0.1:22")
.unwrap();
// 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 = ssh::create_session()
.username("ubuntu")
.private_key_path("./id_rsa")
.connect("127.0.0.1:22")
.unwrap();
// 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 = ssh::create_session()
.username("ubuntu")
.private_key("rsa_string")
.connect("127.0.0.1:22")
.unwrap();
use ssh;
let mut session = ssh::create_session()
.username("username")
.password("password")
.private_key_path("/path/to/rsa")
.connect("127.0.0.1:22")
.unwrap();
log compatible tracing for logging functionalityuse tracing::Level;
use tracing_subscriber::FmtSubscriber;
// this will generate some basic event logs
// a builder for `FmtSubscriber`.
let subscriber = FmtSubscriber::builder()
// all spans/events with a level higher than INFO (e.g, info, warn, etc.)
// will be written to stdout.
.with_max_level(Level::INFO)
// completes the builder.
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
use ssh;
let _listener = TcpListener::bind("127.0.0.1:7777").unwrap();
match ssh::create_session()
.username("ubuntu")
.password("password")
.private_key_path("./id_rsa")
.timeout(Some(std::time::Duration::from_secs(5)))
.connect("127.0.0.1:7777")
{
Err(e) => println!("Got error {}", e),
_ => unreachable!(),
}
curve25519-sha256ecdh-sha2-nistp256diffie-hellman-group14-sha256diffie-hellman-group14-sha1diffie-hellman-group1-sha1 (behind feature "deprecated-dh-group1-sha1")ssh-ed25519rsa-sha2-256rsa-sha2-512rsa-sha (behind feature "deprecated-rsa-sha1")ssh-dss (behind feature "deprecated-dss-sha1")chacha20-poly1305@openssh.comaes128-ctraes192-ctraes256-ctraes128-cbc (behind feature "deprecated-aes-cbc")aes192-cbc (behind feature "deprecated-aes-cbc")aes256-cbc (behind feature "deprecated-aes-cbc")3des-cbc (behind feature "deprecated-des-cbc")hmac-sha2-256hmac-sha2-512hmac-sha1nonezlib@openssh.comzlib (behind feature "zlib")Rust
99.7%