golang实现telnet效果发现ssh异常,在正常的linux是没问题在wsl下提示如下异常

env

  • window11 wsl2.0
  • golang

#异常信息

open failed: administratively prohibited: open failed

解决

1.允许ssh转发tcp端口
vim /etc/ssh/sshd_config
# 允许ssh转发tcp端口
AllowTcpForwarding yes

2.重启ssh服务
systemctl restart sshd

3.ssh端口转发验证
ssh -L 1234:localhost:1234 [email protected]

[bang@0201221459-NB ~]$ ss -lant |grep 1234
LISTEN 0      128        127.0.0.1:1234       0.0.0.0:*
LISTEN 0      128            [::1]:1234          [::]:*

#link