[WSL][ubuntu][原创]windows上ssh WSL的linux子系统

登录后安装

sudo apt install openssh-client openssh-server

修改配置:sudo vi /etc/ssh/ssh_config

#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
    AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
    Port 22
    ListenAddress 0.0.0.0
    PermitRootLogin no
    PasswordAuthentication yes
#   Protocol 2
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,umac-64@openssh.com
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes

重启ssh服务:

sudo service ssh restart

查看自己的ip地址:

ifconfig

fut@DESKTOP-19QNH4E:~$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.21.7.62  netmask 255.255.240.0  broadcast 172.21.15.255
        inet6 fe80::215:5dff:fef7:b154  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:f7:b1:54  txqueuelen 1000  (Ethernet)
        RX packets 48378  bytes 72720775 (72.7 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 9399  bytes 875394 (875.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 32  bytes 4926 (4.9 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32  bytes 4926 (4.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

登录:

ssh fut@172.21.7.62

注意端口22需要加入入站规则

配置Windows防火墙

打开windows Definder的高级设置:

  • 点击左侧“入站规则”
  • 点击右侧“新建规则”
  • 选择“端口”
  • 选择"TCP"
  • 选择“特定本地端口”,并设定值为2222(与之前配置端口映射时的本机端口一致即可)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FL1623863129

你的打赏是我写文章最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值