| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"fmt" |
| 5 |
|
| 6 |
"github.com/appleboy/easyssh-proxy" |
| 7 |
) |
| 8 |
|
| 9 |
func main() { |
| 10 |
// Create MakeConfig instance with remote username, server address and path to private key. |
| 11 |
ssh := &easyssh.MakeConfig{ |
| 12 |
User: "appleboy", |
| 13 |
Server: "example.com", |
| 14 |
Password: "123qwe", |
| 15 |
Port: "22", |
| 16 |
} |
| 17 |
|
| 18 |
// Call Scp method with file you want to upload to remote server. |
| 19 |
// Please make sure the `tmp` floder exists. |
| 20 |
err := ssh.Scp("/root/source.csv", "/tmp/target.csv") |
| 21 |
// Handle errors |
| 22 |
if err != nil { |
| 23 |
panic("Can't run remote command: " + err.Error()) |
| 24 |
} |
| 25 |
fmt.Println("success") |
| 26 |
} |