Hi,
I am trying to find a way to communicate with a remote system that exposes a netconf subsystem over ssh.
Here is an extract of the code I am using to accomplish this:
package main
import (
"net"
)
type clientPassword string
func (p clientPassword) Password(user string) (string, error) {
return string(p), nil
}
func main() {
username := "foo"
password := "bar"
config := &ssh.ClientConfig{
User: username,
Auth: []ssh.ClientAuth{
ssh.ClientAuthPassword(clientPassword(password)),
},
}
if err != nil {
panic("Failed to dial: " + err.Error())
}
defer client.Close()
session, err := client.NewSession()
if err != nil {
panic(err)
}
defer session.Close()
// Request a netconf subsystem
if err := session.RequestSubsystem("netconf"); err != nil {
panic(err)
}
// How do I now interact with the netconf subsystem?
}
I am unsure how I now send the netconf subsystem XML/RPC commands (for e.g. `<?xml version="1.0" encoding="UTF-8"?><hello><capabilities><capability>urn:ietf:params:xml:ns:netconf:base:1.0</capability></capabilities></hello>]]>]]>`) as one cannot use the Start()/Run()/etc. commands to send the data.
I have tried using the session.StdoutPipe() and session.StdinPipe() functions but I cannot get this working either.
Does anyone has an example of how to use the session.StdoutPipe() and session.StdinPipe() functions if that is the way this is supposed to work? Alternatively, has anyone got any experience working with netconf over ssh in golang?
Ciao
Charl