Ubuntu16.04.5 desktop 基本配置及远程桌面

Ubuntu16.04.5 desktop 基本配置及远程桌面

1 基本安装

2 基本配置

2.1 安装ssh服务

sudo apt-get install openssh-server
sudo service sshd status     # 查看状态,默认已启动;

记住用户名密码,可以远程ssh连接;

2.2 查看系统版本

netc@Ubuntu:~$ uname -a
Linux Ubuntu 4.15.0-34-generic #37~16.04.1-Ubuntu SMP Tue Aug 28 10:44:06 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
netc@Ubuntu:~$ cat  /etc/i
ifplugd/         init/            initramfs-tools/ insserv/         insserv.conf.d/  issue            
iftab            init.d/          inputrc          insserv.conf     iproute2/        issue.net        
netc@Ubuntu:~$ cat  /etc/issue
Ubuntu 16.04.5 LTS \n \l

netc@Ubuntu:~$ 

2.3 设置管理员root的密码

netc@Ubuntu:~$ su - 
密码: 
root@Ubuntu:~# passwd 
输入新的 UNIX 密码: 
重新输入新的 UNIX 密码: 
passwd:已成功更新密码
root@Ubuntu:~# 

2.4 设置sudo免密;

只要在%sudo ALL=(ALL:ALL) ALL下面添加一行$username  ALL=(ALL) NOPASSWD: ALL

root@Ubuntu:~# visudo        

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL
netc ALL=(ALL) NOPASSWD: ALL      # 添加的内容

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

root@Ubuntu:~# su - netc
netc@Ubuntu:~$ 

2.5 安装vim编辑软件

netc@Ubuntu:~$ sudo apt-get install vim

2.6 设置固定IP地址

netc@Ubuntu:~$ sudo vim /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
#auto lo
#iface lo inet loopback

# The primary network interface
auto enp7s0
iface enp7s0 inet static
        address 192.168.1.32
        netmask 255.255.255.0
        gateway 192.168.1.1
        # dns-* options are implemented by the resolvconf package, if instatlled
        dns-nameservers 114.114.114.114
        dns-search pcat

2.7 重启网络

sudo systemctl restart networking.service

2.8 修改设置(可选)

将“managed=false”修改为“managed=true”。意思是,将网络连接设置为自定义或手动。#号后面的是注释内容

netc@Ubuntu:~$ sudo vim  /etc/NetworkManager/NetworkManager.conf

[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=true # from false
netc@Ubuntu:~$ sudo service network-manager restart

3 远程桌面-VNC

3.1 设置Ubuntu16.04允许进行远程控制

首先,我们先设置Ubuntu的远程控制,将其设置为允许被远程连接,进入系统-》首选项-》桌面共享,或者直接搜索桌面共享,如图所示:

将【允许其他人查看您的桌面】这一项勾上,然后在安全那项,勾选【要求远程用户输入此密码】,并设置远程密码。并且我们取消勾选【必须为对本机器的每次访问进行确定】(这样做,是为了被远程的时候不需要再确认,否则每次远程都要人为确认才能被远程,会很繁琐)如图所示:

3.2 安装vncserver

sudo apt-get install libtasn1-bin libtasn1-3-bin   # tightvncserver的依赖
netc@Ubuntu:~$ sudo apt-get install xrdp vnc4server tightvncserver

3.3 安装dconf-editor(取消权限限制)

需要取消掉请求加密的功能,否则缺少这一步是无法远程上的,这个时候我们需要安装dconf-editor工具进行配置,

sudo apt-get install dconf-editor

安装完成之后,我们需要打开dconf-editor工具,在桌面搜索dconf-editor打开,如图所示:

打开之后,依次展开org->gnome->desktop->remote-access,然后取消 “requlre-encryption”的勾选即可。如图所示:

3.4 远程连接Ubuntu 16.04

通过VNC工具或者Windows自带的mstsc(远程桌面控制)进行访问就行。
获取当前的IP地址,命令ifconfig即可得到,笔者的当前的Ubuntu的IP地址为:192.168.8.203,然后通过IP地址就可以远程访问了。

方法一、通过VNC Viewer客户端进行访问

大家可以到VNC官网(https://www.realvnc.com/en/connect/download/viewer/)下载最新的版本,根据自己实际情况,选择相对应的版本,如图所示

输入我们需要远程控制的PC主机的IP,如图所示:

成功连接上了,如图所示:

方法二、通过Windows自带远程桌面控制(mstsc)进行访问(个人推荐)

个人比较推荐使用该方法,直接使用Windows自带的远程桌面控制工具进行远程访问,这样就可以不用VNC Viewer。直接打开自带远程桌面控制,输入目标PC的IP地址,如图所示:

通过自带远程桌面控制工具,选择模式【vnc-any】,然后输入IP地址和密码进行登录(其中端口号默认为5900,保持不变就行)如图所示:

成功连接了,如图所示:

猜你喜欢

转载自blog.51cto.com/moerjinrong/2179138
今日推荐