rust ssh2 example channel.read_to_string() no result

89 views Asked by At

I'm new to rust and ssh2 and I ran into this problem while using I used the example provided,there is no output after execution

use ssh2::{Channel, Session};
use std::io::{stdin, stdout, Read, Write};
use std::net::TcpStream;

fn main(){
    let mut sess = Session::new().unwrap();
    sess.set_tcp_stream(TcpStream::connect("127.0.0.1:22").unwrap());
    sess.handshake().unwrap();
    sess.userauth_password("ubuntu", "123").unwrap();
    let mut channel = sess.channel_session().unwrap();
    channel.exec("ls").unwrap();
    channel.send_eof().unwrap();
    let mut s = String::new();
    channel.read_to_string(&mut s).unwrap();
    channel.wait_close().unwrap();
    channel.exit_status().unwrap();
   
}
0

There are 0 answers