File: tsp.rs

package info (click to toggle)
rust-openssh 0.11.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 436 kB
  • sloc: makefile: 2
file content (19 lines) | stat: -rw-r--r-- 507 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use openssh::*;

#[tokio::main]
async fn main() {
    let session = Session::connect("ssh://jon@ssh.thesquareplanet.com:222", KnownHosts::Strict)
        .await
        .unwrap();

    let ls = session.command("ls").output().await.unwrap();
    eprintln!(
        "{}",
        String::from_utf8(ls.stdout).expect("server output was not valid UTF-8")
    );

    let whoami = session.command("whoami").output().await.unwrap();
    assert_eq!(whoami.stdout, b"jon\n");

    session.close().await.unwrap();
}