2 unstable releases
Uses old Rust 2015
0.5.0 | Jul 22, 2016 |
---|---|
0.4.0 | Jul 21, 2016 |
#7 in #thrussh
12KB
253 lines
extern crate thrussh_client;
extern crate thrussh_scp;
extern crate env_logger;
use thrussh_scp::*;
use std::fs::File;
fn main() {
env_logger::init().unwrap();
let mut client = thrussh_client::SSHClient::new("localhost", 22).unwrap();
let key = thrussh_client::load_secret_key("/home/pe/.ssh/id_ed25519").unwrap();
client.session().set_auth_public_key("pe".to_string(), key);
// Run until the authentication has completed.
client.authenticate().unwrap();
// Send a file.
let contents = b"file_contents\n";
let len = contents.len();
client.send_file("/tmp", "blabla", &contents[..], len, 0o644).unwrap();
// Receive the file we just sent.
let file = File::create("blibli").unwrap();
client.receive_file("/tmp/blabla", file).unwrap();
}
Dependencies
~23MB
~226K SLoC