I was previously using asyncssh for python. It has a feature that you can provide an already available connection to connect to a new host. I am looking into the ssh documentation. I don't see any option that can do this trick, not sure if I have to do some tunneling manually.
What I want is to connect to a machine using SSH that has auth, then use that connection to connect to another machine that has different auth then the first machine.
ncmConfig := &ssh.ClientConfig{
User: "xyz",
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Auth: []ssh.AuthMethod{
ssh.Password("xyz!"),
},
}
routerConfig := &ssh.ClientConfig{
User: "xyz1",
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Auth: []ssh.AuthMethod{
ssh.Password("xyz2"),
},
}
ncm := "1.1.1.1"
router := "2.2.2.2
conn, err := ssh.Dial("tcp", ncm+":22", ncmConfig)
if err != nil {
log.Println(err)
}
# how can I use the conn to connect to a new machine.