10个版本
| 0.1.0 |
|
|---|---|
| 0.0.10 | 2024年5月18日 |
| 0.0.7 | 2024年4月30日 |
| 0.0.2 | 2024年3月31日 |
#215 in 密码学
每月827次下载
370KB
9K SLoC
SSH-2.0客户端库
flatline中的算法
- kex
curve25519-sha256@libssh.orgcurve25519-sha256ecdh-sha2-nistp256ecdh-sha2-nistp384ecdh-sha2-nistp521diffie-hellman-group14-sha256diffie-hellman-group16-sha512diffie-hellman-group16-sha256diffie-hellman-group14-sha1diffie-hellman-group18-sha512diffie-hellman-group-exchange-sha256diffie-hellman-group-exchange-sha1diffie-hellman-group15-sha512diffie-hellman-group17-sha512diffie-hellman-group1-sha1
- hostkey
ssh-ed25519rsa-sha2-256rsa-sha2-512ssh-rsassh-dssecdsa-sha2-nistp521ecdsa-sha2-nistp256ecdsa-sha2-nistp384
- 加密
chacha20-poly1305@openssh.comaes256-gcm@openssh.comaes128-gcm@openssh.comaes256-ctraes128-cbcaes192-cbcaes256-cbcaes128-ctraes192-ctrrijndael-cbc@lysator.liu.se3des-cbc
- mac
hmac-sha1hmac-sha1-etm@openssh.comhmac-sha1-96hmac-sha1-96-etm@openssh.comhmac-md5hmac-md5-etm@openssh.comhmac-md5-96hmac-md5-96-etm@openssh.comhmac-sha2-512hmac-sha2-512-etm@openssh.comhmac-sha2-256hmac-sha2-256-etm@openssh.com
- 压缩
zlibzlib@openssh.com
示例
- echo hello
#[tokio::main]
async fn main() {
use flatline::session::Session;
use flatline::handshake::Config;
use tokio::net::TcpStream;
use flatline::session::Userauth;
use flatline::channel::ExitStatus;
let socket = TcpStream::connect("192.168.8.190:22").await.unwrap();
let config = Config::deafult_with_behavior();
let session = Session::handshake(config, socket).await.unwrap();
let status = session.userauth_password("zhou", "123456").await.unwrap();
assert!(matches!(status, Userauth::Success));
let mut channel = session.channel_open_default().await.unwrap();
channel.exec("echo \"hello\"").await.unwrap();
loop {
let msg = channel.recv().await.unwrap();
match msg {
flatline::channel::Message::Close => break,
flatline::channel::Message::Eof => break,
flatline::channel::Message::Stdout(data) => assert_eq!(data, b"hello\n"),
flatline::channel::Message::Stderr(_) => unreachable!(),
flatline::channel::Message::Exit(status) => assert!(matches!(status, ExitStatus::Normal(0))),
}
}
}
[!WARNING] flatline目前处于beta版本,可能包含破坏性变更!
依赖项
~7–10MB
~187K SLoC