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:
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:
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.
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
MakeConfigstruct, names could beReadFileorScpGet.Proposed Method Signature:
This method would establish an SSH session, execute the necessary remote command (like
cator internal SFTP/SCP logic), and return anio.Reader.This pattern would allow handling the output efficiently using standard Go I/O utilities, like copying directly to a local file:
Happy to do submit PR myself if this is something you'd like to add to the library.