This question already has an answer here:
How to execute the scp -i ssh " . " using Go?
I have used the following code snippet.
cmd := exec.Command("scp -i dragonstone.pem <user>@ubuntu:<file location> .")
err = cmd.Run()
</div>
This question already has an answer here:
How to execute the scp -i ssh " . " using Go?
I have used the following code snippet.
cmd := exec.Command("scp -i dragonstone.pem <user>@ubuntu:<file location> .")
err = cmd.Run()
</div>
I will do this.
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
cmd := "scp"
args := []string{"-i", "dragonstone.pem", "<user>@ubuntu:<file location>", "."}
if err := exec.Command(cmd, args...).Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println("Successfully.")
}