# 默认用户 **管理员权限打开powershell,关掉子系统** ```bash wsl --shutdown ``` **设置默认用户 ** ```bash config --default-user ``` ubuntu 2204版本设置root为默认 ``` ubuntu2204 config --default-user root ``` # 换源中科大 ```bash sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && apt update ``` # 开启ssh ## 安装 ``` sudo apt update sudo apt install openssh-server ``` ## 配置 默认密码wslrootpwd,可以修改 ``` echo 'root:wslrootpwd' | sudo chpasswd echo -e "# This is the sshd server system-wide configuration file. See\n# sshd_config(5) for more information.\n\n# What ports, IPs and protocols we listen for\nPort 22\n# Use these options to restrict which interfaces/protocols sshd will bind to\nListenAddress 0.0.0.0\nProtocol 2\n\n# Authentication:\nPermitRootLogin yes\n# Change to yes to enable challenge-response passwords (beware issues with\n# some PAM modules and threads)\nChallengeResponseAuthentication yes\nPasswordAuthentication yes\n\n# AcceptEnv LANG LC_*\n# Allow client to pass locale environment variables\n\n# Subsystem sftp /usr/lib/openssh/sftp-server" > /etc/ssh/sshd_config sudo service ssh restart ``` ## 获取wsl的ip ``` ip addr ``` 比如 ``` eth0: mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:15:5d:05:40:ad brd ff:ff:ff:ff:ff:ff inet 172.24.178.150/20 brd 172.24.191.255 scope global eth0 ``` ip就是172.24.178.150 ssh链接即可 # 禁用windows环境变量 防止本地的部分变量污染wsl内部 在wsl 的 ubuntu中编辑`/etc/wsl.conf`,输入: ```text [interop] enabled = false appendWindowsPath = false ``` 退出保存之后,需要重启wsl。 # 修改host模式 便于使用win的~~科学工具~~ 在`%USERPROFILE%`目录下的`.wslconfig`文件中添加如下配置 ``` [experimental] networkingMode=mirrored dnsTunneling=true firewall=true autoProxy=true ``` 重启wsl2即可 # 增大内存上限 ``` [wsl2] memory=32GB ``` Loading... # 默认用户 **管理员权限打开powershell,关掉子系统** ```bash wsl --shutdown ``` **设置默认用户 ** ```bash <wsl> config --default-user <username> ``` ubuntu 2204版本设置root为默认 ``` ubuntu2204 config --default-user root ``` # 换源中科大 ```bash sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list && apt update ``` # 开启ssh ## 安装 ``` sudo apt update sudo apt install openssh-server ``` ## 配置 默认密码wslrootpwd,可以修改 ``` echo 'root:wslrootpwd' | sudo chpasswd echo -e "# This is the sshd server system-wide configuration file. See\n# sshd_config(5) for more information.\n\n# What ports, IPs and protocols we listen for\nPort 22\n# Use these options to restrict which interfaces/protocols sshd will bind to\nListenAddress 0.0.0.0\nProtocol 2\n\n# Authentication:\nPermitRootLogin yes\n# Change to yes to enable challenge-response passwords (beware issues with\n# some PAM modules and threads)\nChallengeResponseAuthentication yes\nPasswordAuthentication yes\n\n# AcceptEnv LANG LC_*\n# Allow client to pass locale environment variables\n\n# Subsystem sftp /usr/lib/openssh/sftp-server" > /etc/ssh/sshd_config sudo service ssh restart ``` ## 获取wsl的ip ``` ip addr ``` 比如 ``` eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:15:5d:05:40:ad brd ff:ff:ff:ff:ff:ff inet 172.24.178.150/20 brd 172.24.191.255 scope global eth0 ``` ip就是172.24.178.150 ssh链接即可 # 禁用windows环境变量 防止本地的部分变量污染wsl内部 在wsl 的 ubuntu中编辑`/etc/wsl.conf`,输入: ```text [interop] enabled = false appendWindowsPath = false ``` 退出保存之后,需要重启wsl。 # 修改host模式 便于使用win的~~科学工具~~ 在`%USERPROFILE%`目录下的`.wslconfig`文件中添加如下配置 ``` [experimental] networkingMode=mirrored dnsTunneling=true firewall=true autoProxy=true ``` 重启wsl2即可 # 增大内存上限 ``` [wsl2] memory=32GB ``` Last modification:August 17, 2024 © Allow specification reprint Like 1 如果觉得我的文章对你有用,请随意赞赏
One comment
[...]双十二没忍住买了一台天钡迷你主机,这里记录一下一系列环境配置总结右键修改脚本其他软件腾讯管家 桌面整理 微信 QQ紫色 vs安装 c++环境(cuda 等会用到)miniforgecuda driverwsl2debian12安装自定义位置systemdhttps://blog.skyw.cc/archives/282.html宝塔[...]