Skip to content

xentrick/sshrs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sshrs

An SSH library written in Rust. This wraps the ssh2 bindings library and makes it easier to work with. This is simply meant to make quick and easy SSH connections while maintaining an active session.

Note: Forwarding, Tunnels, and interactive shell have not been fully implemented.

Usage

Connection:

let mut tunn = ssh::SSH::new(&HOST, 22);
tunn.connect(&USR, &PWD).unwrap();
assert_eq!(tunn.authed(), true);

Connection using ssh-agent:

let mut tunn = ssh::SSH::new(&HOST, 22);
tunn.connect_agent(&USR).unwrap();
assert_eq!(tunn.authed(), true);

Execute command:

let result = tunn.run_command("uname -a").unwrap();
println!("Command Output: {}", result)

Upload a file:

let src = Path::new("/home/ssh/important.txt");
let dest = Path::new("/tmp/destination.txt");
let result = tunn.upload_file(&src, dest);

Download a file:

let fpath = Path::new("/tmp/downloadme.tar.gz");
let (contents, stat) = tunn.get_file(fpath).unwrap();
println!("File Contents: {}", String::from_utf8(contents).unwrap());

About

Rust library that wraps ssh2. This makes the library a bit easier to work with.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages