feat: update ssh-rs

This commit is contained in:
2022-09-04 16:54:01 +08:00
parent 338d2720ac
commit 36e1609002
2 changed files with 26 additions and 4 deletions

View File

@@ -508,9 +508,9 @@ dependencies = [
[[package]]
name = "sha2"
version = "0.10.3"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899bf02746a2c92bf1053d9327dadb252b01af1f81f90cdb902411f518bc7215"
checksum = "cf9db03534dff993187064c4e0c05a5708d2a9728ace9a8959b77bedf415dac5"
dependencies = [
"cfg-if",
"cpufeatures",

View File

@@ -1,4 +1,6 @@
use ssh_rs::{Session, ssh};
use std::thread::sleep;
use std::time::Duration;
use ssh_rs::{ChannelShell, Session, ssh};
use ssh_rs::key_pair::KeyPairType;
fn main() {
@@ -16,4 +18,24 @@ fn main() {
let exec = session.open_exec().unwrap();
let v = exec.send_command("ls -l -a --color ~/").unwrap();
println!("{}", String::from_utf8_lossy(&v).to_string());
println!("<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>");
let mut shell: ChannelShell = session.open_shell().unwrap();
run_shell(&mut shell);
shell.close().ok();
session.close().ok();
}
fn run_shell(shell: &mut ChannelShell) {
sleep(Duration::from_millis(500));
let vec = shell.read().unwrap();
println!("{}", String::from_utf8(vec).unwrap());
shell.write(b"ls\n").unwrap();
sleep(Duration::from_millis(500));
let vec = shell.read().unwrap();
println!("{}", String::from_utf8(vec).unwrap());
}