rust-lang / rust-lang/ssh2-rs

Error in scp_send to Windows Hosts

Open
#276 1 comment 3 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'm hopeful that this is PEBCAK but I can't seem to resolve it no matter what I try.
Any attempts to scp_send a file to a windows host seem to fail on anything other than a relative filepath with no directory structures, all other paths panic at runtime with value: Error { code: Session(-28), msg: "failed to send file" }'.

For example the following code works but it places 'remote' in $HOME of the user and literally includes the single tics in the filename:

    let tcp = TcpStream::connect("IP.ADDR.OF.HOST:22").unwrap();
    let mut sess = Session::new().unwrap();
    sess.set_tcp_stream(tcp);
    sess.handshake().unwrap();

    sess.userauth_password(r"DOMAIN\username", "DomainUserPassword").unwrap();
    
    let buf = std::path::PathBuf::from("remote");
    let mut remote_file = sess.scp_send(buf.as_path(),
                                       0o644, 10, None).unwrap();

    remote_file.write(b"1234567890").unwrap();
    remote_file.send_eof().unwrap();
    remote_file.wait_eof().unwrap();
    remote_file.close().unwrap();
    remote_file.wait_close().unwrap();

ANY other pattern passed fails with this error including paths expecting that relative path to remain true. Scp to the host works fine from both linux and windows terminals. I see in the Event Viewer logs that there is no authentication issue so I'm kind of at a loss.

Examples of other paths I have attempted and this list is not exhaustive:

/C:/remote
c:/remote
/c/remote
/C/remote
C:\\remote
c:\\remote
c\\remote
C\\remote
Downloads/remote
Downloads\\remote

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 with the provided Rust reproducer and the scp_send call, testing the listed Windows path forms against the behavior described. Compare these results with the working terminal scp behavior and determine what successful remote-path handling should look like; done means sending the file succeeds for supported Windows paths without a runtime error.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.