当前位置:   article > 正文

【Windows】Windows中wsl安装Ubuntu系统并使用xshell连接_wsl ubuntu ssh

wsl ubuntu ssh

Windows中wsl安装系统并使用xshell连接

一、系统安装

  1. 访问https://raw.githubusercontent.com/microsoft/WSL/master/distributions/DistributionInfo.json下载对应版本的系统,此博客以Ubuntu-20.04为例
    下载在这里插入图片描述CSDN下载地址: https://download.csdn.net/download/qq_42454367/89346215

  2. 下载后打开Windows PowerShell,运行
    Add-AppxPackage D:\system\Ubuntu2204LTS-230518_x64.appx
    其中D:\system\Ubuntu2204LTS-230518_x64.appx为下载后的文件路径,
    运行完成后在开始菜单点击系统
    在这里插入图片描述

  3. 在打开的页面输入新账号、密码,即安装完成。
    在这里插入图片描述

二、ssh配置

  1. 切换到root账户,并重置密码
    在这里插入图片描述
  2. 修改apt的镜像地址,因为直接使用apt-get install openssh-server,会报错,提示
    Err:1 http://archive.ubuntu.com/ubuntu jammy-updates/main amd64 openssh-sftp-server amd64 1:8.9p1-3ubuntu0.1 404 Not Found [IP: 185.125.190.39 80]
  • 输入vim /etc/apt/sources.list
  • 将sources.list中所有http://archive.ubuntu.com/ubuntu/改为http://cn.archive.ubuntu.com/ubuntu/后,输入:wq!保存退出
  • 执行apt-get update
  • 执行apt-get install openssh-server在这里插入图片描述在这里插入图片描述
  1. 输入vim /etc/ssh/sshd_config,修改sshd_config的Port、PasswordAuthentication配置
  • Port取消注释,并改为10022或其它端口,防止端口冲突
  • PasswordAuthentication取消注释
    在这里插入图片描述
  1. 修改完毕后,输入systemctl restart ssh进行重启
    在这里插入图片描述

三、xshell连接

  1. 打开xshell,输入主机和端口号,用户名和密码输入系统安装时的用户名和密码即可。
    在这里插入图片描述
    在这里插入图片描述
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/天景科技苑/article/detail/992747
推荐阅读
相关标签
  

闽ICP备14008679号