Closed
Description
- Use Redis over SSH channels
sshConfig := &ssh.ClientConfig{
User: "root",
Auth: []ssh.AuthMethod{ssh.Password("password")},
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
Timeout: 15 * time.Second,
}
client, err := ssh.Dial("tcp", "remoteIp:22", sshConfig)
if err != nil {
log.Println(fmt.Errorf("%v", err))
}
cli := redis.NewClient(&redis.Options{
Addr: net.JoinHostPort("127.0.0.1", "6379"),
Dialer: func(ctx context.Context, network, addr string) (net.Conn, error) {
log.Println(fmt.Sprintf("%s %s", network, addr))
return client.Dial(network, addr)
},
})
_, err = cli.Ping(context.Background()).Result()
if nil != err {
log.Println(fmt.Errorf("%v", err))
}
-
Error:
ssh: tcpChan: deadline not supported -
Reason:
in the redis/interal/pool/conn.og usecn.netConn.SetReadDeadline
andcn.netConn.SetWriteDeadline