rust-lang / rust-lang/ssh2-rs

How to use a existing channel ssh connect to another remote host?

Open
#231 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Rust
Stars
566
Forks
163
Avg merge
4h 51m
Merged PRs (30d)
2

Description

I want to connect to another remote host through a springboard machine that is already connected.
My code as follows:

let tcp = TcpStream::connect("xx").unwrap();
let mut sess = Session::new().unwrap();
sess.set_tcp_stream(tcp);
sess.handshake().unwrap();
sess.userauth_password("user", "passwd").unwrap();
let mut channel = sess.channel_session().unwrap();
channel.request_pty(
  "xterm",
   None,
   Some((80, 24, 0, 0)),).unwrap();
channel.shell().unwrap();
channel.write(b"ssh xx@xx \n").unwrap();
//channel.write(b"yes \n").unwrap();
channel.write(b"passwd\n").unwrap();
channel.write(b"ls\n").unwrap()

It doesn't work, would someone help me. Thank you in advance

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the reported Rust calls to Session, channel_session, request_pty, shell, and write in the ssh2-rs documentation and examples. Reproduce the nested SSH attempt and determine whether the reported behavior is a library bug or an unsupported usage pattern; document the result and a verified resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
18/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.