MCPcopy Create free account
hub / github.com/appleboy/easyssh-proxy / Scp

Method Scp

easyssh.go:550–571  ·  view source on GitHub ↗

Scp uploads sourceFile to remote machine like native scp console app.

(sourceFile string, etargetFile string)

Source from the content-addressed store, hash-verified

548
549// Scp uploads sourceFile to remote machine like native scp console app.
550func (ssh_conf *MakeConfig) Scp(sourceFile string, etargetFile string) error {
551 session, client, err := ssh_conf.Connect()
552 if err != nil {
553 return err
554 }
555 defer func() { _ = client.Close() }()
556 defer func() { _ = session.Close() }()
557
558 src, srcErr := os.Open(sourceFile)
559
560 if srcErr != nil {
561 return srcErr
562 }
563 defer func() { _ = src.Close() }()
564
565 srcStat, statErr := src.Stat()
566
567 if statErr != nil {
568 return statErr
569 }
570 return ssh_conf.WriteFile(src, srcStat.Size(), etargetFile)
571}

Callers 6

TestSCPCommandFunction · 0.95
TestSCPCommandWithKeyFunction · 0.95
mainFunction · 0.95
mainFunction · 0.95

Calls 2

ConnectMethod · 0.95
WriteFileMethod · 0.95

Tested by 4

TestSCPCommandFunction · 0.76
TestSCPCommandWithKeyFunction · 0.76