Skip to content

ImSingee/scp

Repository files navigation

scp in Go

Install

go get -u github.com/ImSingee/scp

Usage

Go Reference

Simple Copy

package main
import "golang.org/x/crypto/ssh"
import "github.com/ImSingee/scp"

func main() {
    // make session
    client, _ := ssh.Dial("tcp", "remote-addr:22", &ssh.ClientConfig{
		User: "root",
		Auth: []ssh.AuthMethod{
			ssh.Password("root"),
		},
		HostKeyCallback: ssh.InsecureIgnoreHostKey(),
		BannerCallback:  ssh.BannerDisplayStderr(),
	})
    defer client.Close()

	session, _ := client.NewSession()
    defer session.Close()
    
    // Copy!
    err := scp.Copy(session, "/path/to/local/file", "/path/to/remote/file")
    
    if err != nil {
    panic(err)
    }
}

The behavior is same as scp [-r] /path/to/local/file remote-addr:/path/to/remote/file

Custom Use

Please read protocol_test.go

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages