go-sftp
A pure SFTP protocol implementation for Go!
This library provides an SFTP client and server (not yet) implementation and
low-level packet definitions for SFTP version 3. The cmd/sftp
package contains
a SFTP commandline client with interactive shell and auto-completion.
cli, _ := sftp.NewClient(sshConn)
list, _ := cli.List("/tmp")
for _, fileInfo := range list {
fmt.Printf("%s %dbytes\n", fileInfo.Name(), fileInfo.Size())
}
reader, _ := cli.FileReader("/etc/passwd")
io.Copy(os.Stdout, reader)
f, _ := os.Open("/tmp/foobar")
writer, _ := cli.FileWriter("/tmp/barfoo")
io.Copy(writer, f)
cli.Put("/tmp/local_file", "/tmp/remote_file")
cli.Get("/tmp/remote_file", "/tmp/local_file")
reader, _ = cli.FileReader("/tmp/source")
writer, _ = cli.FileWriter("/tmp/dest")
io.Copy(writer, reader)
cli.Remove("/tmp/foobar")
cli.Rename("/tmp/bar", "/tmp/foo")
cli.MkDir("/tmp/mydir")
cli.RmDir("/tmp/mydir")
go-sftp
is not yet complete an some protocol features are still missing. In
addition, the server implementation is postponed until the client is fully
functional.