我启动了一个 sshd(使用 go-ssh)来监听 ssh-client,
然后运行
ssh -L 2345:127.0.0.1:5244 127.0.0.1 -p 2022 -N
.
我没有收到来自客户端的任何消息(包括“direct-tcpip”),但我可以通过
127.0.0.1:2345
访问网络。
OpenSSH如何实现本地端口转发?
我希望我能从客户那里收到“direct-tcpip”。
sshConn, ch, globalRequestCh, err := ssh.NewServerConn(conn, config)
if err != nil {
log.Println("Handshake err", err)
return
}
log.Println("sshd serving", "ssh client", sshConn.RemoteAddr())
go func() {
// handle newChan
for newChannel := range ch {
log.Println("new channel", "type", newChannel.ChannelType())
switch newChannel.ChannelType() {
case "session":
case "direct-tcpip":
default:
}
}
}()
// handle globalRequest
for globalRequest := range globalRequestCh {
log.Println("global request", "type", globalRequest.Type)
switch globalRequest.Type {
case "tcpip-forward":
case "cancel-tcpip-forward":
default:
}
}