logman/sftp.go

44 lines
586 B
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
)
var (
2019-08-19 20:43:01 -05:00
dstPath string = "/home/wyatt/"
srcPath string = "/var/log/"
2019-08-19 20:43:01 -05:00
filename string = "dpkg.log"
)
func getFile(client *ssh.Client) {
sftp, err := sftp.NewClient(client)
if err != nil {
fmt.Errorf("FUCK")
}
defer sftp.Close()
srcFile, err := sftp.Open(srcPath + filename)
if err != nil {
fmt.Errorf("FUCK")
}
defer srcFile.Close()
2019-08-19 20:43:01 -05:00
dstFile, err := os.Create(dstPath + filename)
if err != nil {
fmt.Errorf("FUCK")
}
defer dstFile.Close()
srcFile.WriteTo(dstFile)
}