<分区>
如何使用 Go 执行 scp -i ssh ". "?
我使用了以下代码片段。
cmd := exec.Command("scp -i dragonstone.pem <user>@ubuntu:<file location> .")
err = cmd.Run()
<分区>
如何使用 Go 执行 scp -i ssh ". "?
我使用了以下代码片段。
cmd := exec.Command("scp -i dragonstone.pem <user>@ubuntu:<file location> .")
err = cmd.Run()
最佳答案
我会做的。
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.")
}
关于go - 我从客户端机器上使用 Go 运行 scp -i ssh "<filepath of remote linux machine> . ",但它返回 "no such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55034988/