在Windows Subsystem for Linux(简称WSL)上安装的Ubuntu1804中快速搭建ssh+Unity桌面环境

分类:笔记 日期:2020-04-22 作者:caocaofff 浏览:1232

前提:Windows10必须是64位,需开启WSL功能(控制面板--程序--启用或关闭WIndows功能--适用于Linux的Windows子系统),并且在应用商店安装好Ubuntu1804(搜索WSL--安装Ubuntu18.04LTS)。

废话不多说,初始化完Ubuntu18.04LTS后,按下面的命令走:

1.备份软件源列表文件

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2.编辑源列表文件

sudo vim /etc/apt/sources.list

内容全部删除,替换为阿里源:

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

3.更新软件列表

sudo apt-get update

4.更新软件包

sudo apt-get upgrade

5.[可选步骤] 检查ssh版本

dpkg -l|grep ssh

6.[可选步骤] 如果开启ssh服务后无法连接可换成1.6版本
卸载openssh-server、openssh-client、openssh-sftp-server

sudo apt-get remove openssh-server openssh-client openssh-sftp-server -y

安装openssh-server、openssh-client、openssh-sftp-server

sudo apt-get install openssh-server openssh-client openssh-sftp-server -y

7.备份ssh服务配置文件

sudo cp /etc/ssh/sshd_config  /etc/ssh/sshd_config.bak

8.编辑ssh服务配置文件

sudo vim /etc/ssh/sshd_config

修改内容:

Port 2222  #默认的是22,但是windows有自己的ssh服务,也是监听的22端口,所以这里要改一下
UsePrivilegeSeparation no
PasswordAuthentication yes
AllowUsers yourusername # 这里改成你登陆WSL用的用户名

9.重启ssh服务

sudo service ssh --full-restart

10.安装xorg(包括显卡驱动、图形环境库等等一系列软件包)

sudo apt-get install xorg -y

11.[可选步骤] 安装xrdp(一种开源的远程桌面协议(RDP)服务器)

sudo apt-get install xrdp -y

12.[可选步骤] 配置xrdp(配置端口)

sudo sed -i 's/port=3389/port=3390/g' /etc/xrdp/xrdp.ini

13.[可选步骤] 重启xrdp服务

sudo service xrdp restart

14.安装桌面环境

sudo apt-get install ubuntu-desktop unity compizconfig-settings-manager -y

15.安装VcXsrv Server
安装完成后,启动xlaunch,在Display settings界面选择“one large window”,Display number设置成0,其它默认即可(一直下一步直至结束),完成后会打开一个VcXsrv Server窗口

16.配置compiz窗口管理器
设置变量

export DISPLAY=localhost:0

配置VcXsrv Server,只勾选Commands、Composite、OpenGL、Expo、Ubuntu Unity Plugin,然后点击close关闭ccsm

ccsm

17.启动compiz (打开桌面)

compiz

18.[以下全部可选步骤] 中文支持

#输入法框架
sudo apt-get install fcitx dbus-x11 fcitx-libs libfcitx-qt0 -y

#安装字体管理包
sudo apt-get install --assume-yes fontconfig

#安装中文字体
sudo mkdir -p /usr/share/fonts/windows
sudo cp -r /mnt/c/Windows/Fonts/*.ttf /usr/share/fonts/windows/

#清除字体缓存
fc-cache

#生成中文环境
sudo locale-gen zh_CN.UTF-8

#编辑系统环境变量文件
sudo vim /etc/profile
export DISPLAY=localhost:0
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8

#立即生效系统环境变量
source /etc/profile
CC版权: 本篇博文采用《CC 协议》,转载必须注明作者和本文链接

评论 (暂无评论)

发表评论

昵称:  
邮箱:  
网址:

验证码:captcha