logman/sftp.go
2019-08-19 21:43:01 -04:00

44 lines
586 B
Go

package main
import (
"fmt"
"os"
"github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
)
var (
dstPath string = "/home/wyatt/"
srcPath string = "/var/log/"
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()
dstFile, err := os.Create(dstPath + filename)
if err != nil {
fmt.Errorf("FUCK")
}
defer dstFile.Close()
srcFile.WriteTo(dstFile)
}