Is there a way to mount a ssh device with Go using an entry in fstab where the mount options are defined. I have been trying syscall.Mount without success.
func main() {
src := "jeanluc@<remote IP>:/home/jeanluc"
target := "/home/jeanluc/my-mnt/ursule_jeanluc"
fs := "fuse.sshfs"
err := syscall.Mount(src, target, fs, 0, "rw")
if err != nil {
log.Fatal(err)
}
}
2018/01/20 11:31:07 operation not permitted exit status 1
A user mount using the fstab entry works fine.
sshfs#jeanluc@<remote IP>:/home/jeanluc /home/jeanluc/my-mnt/ursule_jeanluc fuse user,noauto,uid=1000,gid=1000,follow_symlinks,defaults 0 0
Edit:
Following Marc's advise below here is what worked for me:
cmd := exec.Command("mount /home/jeanluc/my-mnt/ursule_jeanluc")
// capture STDOUT
var out bytes.Buffer
cmd.Stdout = &out
// run cmd
err := cmd.Run()
if err != nil {
log.Fatal(err)
}
// print STDOUT
fmt.Printf("%s", out.String())