appleboy / appleboy/easyssh-proxy

ReadFile or ScpGet

Open
#100 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
349
Forks
64
PR merge metrics
No merged PRs in 30d

Description

Have you consider adding a new method to copy a file from a remote ssh server to the client?

Could be implemented by adding a method to the `MakeConfig` struct, names could be `ReadFile` or `ScpGet`.

#### Proposed Method Signature:

```go
func (ssh_conf *MakeConfig) ReadFile(remoteFile string) (io.Reader, error)
// OR
func (ssh_conf *MakeConfig) ScpGet(remoteFile string) (io.Reader, error)
```

This method would establish an SSH session, execute the necessary remote command (like `cat` or internal SFTP/SCP logic), and return an `io.Reader`.

This pattern would allow handling the output efficiently using standard Go I/O utilities, like copying directly to a local file:

```go
reader, err := ssh.ReadFile("/remote/path/file.dat")
if err != nil { /* ... */ }

// Copy the remote stream directly to a local file
localFile, err := os.Create("/local/path/file.dat")
if err != nil { /* ... */ }
defer localFile.Close()

_, err = io.Copy(localFile, reader)
```

Happy to do submit PR myself if this is something you'd like to add to the library.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the MakeConfig struct and the existing SSH session or command-handling entry points in the library. Compare the proposed ReadFile and ScpGet APIs, then define the remote-file streaming behavior and error handling; the work is done when one supported method copies a remote file through an io.Reader and has corresponding coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.