2 Star 7 Fork 0

陈年旧事. / ssh-rs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ssh-rs ✨

English | 简体中文

rust实现的ssh2.0客户端。

如果在使用中遇到任何问题,欢迎 issues 或者 PR

连接方式:

1. 密码连接:

fn main() {
    let session = ssh::create_session()
        .username("ubuntu")
        .password("password")
        .connect("ip:port")
        .unwrap()
        .run_local();
}

2. 公钥连接:

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现在使用兼容logtracing 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目录
  1. 执行单个命令
  2. 通过scp传输文件
  3. 启动一个pty
  4. 运行一个交互式的shell
  5. 使用非tcp连接
  6. 自行配置密码组

算法支持:

1. 密钥交换算法

  • curve25519-sha256
  • ecdh-sha2-nistp256

2. 主机密钥算法

  • ssh-ed25519
  • rsa-sha2-512
  • rsa-sha2-256
  • rsa-sha (features = ["deprecated-rsa-sha1"])
  • ssh-dss (features = ["deprecated-dss-sha1"])

3. 加密算法

  • chacha20-poly1305@openssh.com
  • 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"])

4. MAC算法

  • hmac-sha2-256
  • hmac-sha2-512
  • hmac-sha1

5. 压缩算法

  • none
  • zlib (behind feature "zlib")

☃️ 会继续添加其它算法。

MIT License Copyright (c) 2021-2022 Kang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

rust实现的 ssh-2.0 client 协议 展开 收起
Rust 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Rust
1
https://gitee.com/gaoxiangkang/ssh-rs.git
git@gitee.com:gaoxiangkang/ssh-rs.git
gaoxiangkang
ssh-rs
ssh-rs
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891