Giter VIP home page Giter VIP logo

ssh-rs's Introduction

In addition to encryption library, pure RUST implementation of SSH-2.0 client protocol

Because there is a lot of unfinished work, there may be problems if you compile the code directly from the main branch

Quick example (简单例子):

fn main() {
    let mut session = ssh::create_session();
    session.is_usage_log(true);
    session.set_user_and_password("root", "123456");
    session.connect("127.0.0.1:22").unwrap();
    
    // exec(&mut session);
    // shell(&mut session);
    // t_shell(&mut session);
    
  
    // let mut scp = session.open_scp().unwrap();
    // file upload
    // scp.upload("localPath", "remotePath").unwrap();
    // file download
    // scp.download("localPath", "remotePath").unwrap();
}

fn exec(session: &mut Session) {
    let exec: ChannelExec = session.open_exec().unwrap();
    let vec = exec.send_command("ls -all").unwrap();
    println!("{}", String::from_utf8(vec).unwrap());
}

fn shell(session: &mut Session) {
    let mut shell = session.open_shell().unwrap();
    thread::sleep(time::Duration::from_millis(200));
    let vec = shell.read().unwrap();
    let result = String::from_utf8(vec).unwrap();
    println!("{}", result);
    shell.write(b"ls -a\n").unwrap();
    thread::sleep(time::Duration::from_millis(200));
    let vec = shell.read().unwrap();
    let result = String::from_utf8(vec).unwrap();
    println!("{}", result);
    shell.close().unwrap();
}

fn t_shell(session: &mut Session) {
    let mut shell = session.open_shell().unwrap();
    loop {

        sleep(Duration::from_millis(300));

        let vec = shell.read().unwrap();
        if vec.is_empty() { continue }
        stdout().write(vec.as_slice()).unwrap();
        stdout().flush().unwrap();

        let mut cm = String::new();
        stdin().read_line(&mut cm).unwrap();
        shell.write(cm.as_bytes()).unwrap();

    }
}

Supported algorithms (支持的算法):

algorithms is supported
curve25519-sha256
ecdh-sha2-nistp256
ssh-ed25519
rsa
[email protected]

Supported authentication modes (支持的身份验证方式):

user auth is supported
publickey ×
password
hostbased ×

Supported channels (支持的连接通道)

channel is supported
shell
exec
subsystem ×

Not currently supported sftp (目前不支持 sftp)

ssh-rs's People

Contributors

1148118271 avatar sheshowered avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.