2019-08-18 17:12:47 -05:00
|
|
|
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/"
|
2019-08-18 17:12:47 -05:00
|
|
|
srcPath string = "/var/log/"
|
2019-08-19 20:43:01 -05:00
|
|
|
filename string = "dpkg.log"
|
2019-08-18 17:12:47 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
2019-08-18 17:12:47 -05:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Errorf("FUCK")
|
|
|
|
}
|
|
|
|
|
|
|
|
defer dstFile.Close()
|
|
|
|
|
|
|
|
srcFile.WriteTo(dstFile)
|
|
|
|
}
|