rust实现的ssh2.0客户端。
如果在使用中遇到任何问题,欢迎 issues 或者 PR 。
fn main() {
let session = ssh::create_session()
.username("ubuntu")
.password("password")
.connect("ip:port")
.unwrap()
.run_local();
}
fn main() {
let session = ssh::create_session()
.username("ubuntu")
.password("password")
.private_key_path("./id_rsa") // 文件地址
.connect("ip:port")
.unwrap()
.run_local();
}
fn main() {
let session = ssh::create_session()
.username("ubuntu")
.password("password")
.private_key("rsa_string") // 文件字符串
.connect("ip:port")
.unwrap()
.run_local();
}
本crate现在使用兼容log
的tracing
crate记录log
使用下面的代码片段启用log
use 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");
ssh::create_session().timeout(Some(std::time::Duration::from_secs(5)));
- 更多使用样例请参考examples目录
curve25519-sha256
ecdh-sha2-nistp256
ssh-ed25519
rsa-sha2-512
rsa-sha2-256
rsa-sha
(features = ["deprecated-rsa-sha1"])ssh-dss
(features = ["deprecated-dss-sha1"])
[email protected]
aes128-ctr
aes192-ctr
aes256-ctr
aes128-cbc
(features = ["deprecated-aes-cbc"])aes192-cbc
(features = ["deprecated-aes-cbc"])aes256-cbc
(features = ["deprecated-aes-cbc"])3des-cbc
(features = ["deprecated-des-cbc"])
hmac-sha2-256
hmac-sha2-512
hmac-sha1
none
zlib
(behind feature "zlib")