Hi, I'd like to SSH to a remote host and run an arbitrary command. I found
this pretty difficult to do with existing Go libraries.
The first problem I had was around escaping; commands run locally are
appropriately escaped but I found it difficult to get the right escaping
for commands run remotely. As an example, this hangs, I believe because of
the {<& in the middle of the command.
cmd := exec.Command("ssh", "remote-host", "echo", "zdUZUKv{<&MsZG")
bits, err := cmd.CombinedOutput()
if err != nil {
log.Fatal(err)
}
os.Stdout.Write(bits)
Note exec.Command("echo", "{<&") runs just fine.
I then wondered if creating a ssh Session (via golang.org/x/crypto/ssh) and
running the command would help. But I wasn't able to get this working that
well; when I run exec.Command("ssh", "remote-host"), the ssh command will
parse my local .ssh/config and pull the appropriate settings from there,
but the Go library doesn't.
- Is there a tool or library for appropriately escaping commands run on a
remote machine? I understand this can lead to security problems and am
worried about getting this wrong
- Is there a tool or library for parsing SSH configs & returning the
appropriate configuration for a host? I found one community library, but
the parser was not implemented very well.
Thanks for your help,
Kevin
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.