Ubuntu16.04.5 desktop 基本配置及遠程桌面
1 基本安裝
略
2 基本設置
2.1 安裝ssh服務
sudo apt-get install openssh-server
sudo service sshd status # 查看狀態,默認已啓動;
記住用戶名密碼,可以遠程ssh連接;
2.2 查看系統版本
user@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
user@Ubuntu:~$ cat /etc/i
ifplugd/ init/ initramfs-tools/ insserv/ insserv.conf.d/ issue
iftab init.d/ inputrc insserv.conf iproute2/ issue.net
user@Ubuntu:~$ cat /etc/issue
Ubuntu 16.04.5 LTS \n \l
user@Ubuntu:~$
2.3 設置管理員root的密碼
user@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
user@Ubuntu:~$
2.5 安裝vim編輯軟件
user@Ubuntu:~$ sudo apt-get install vim
2.6 設置固定IP地址
user@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”。意思是,將網絡連接設置爲自定義或手動。#號後面的是註釋內容
user@Ubuntu:~$ sudo vim /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
[ifupdown]
managed=true # from false
user@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的依賴
user@Ubuntu:~$ sudo apt-get install xrdp vnc4server tightvncserver
### 3.3 安裝dconf-editor(取消權限限制)
需要取消掉請求加密的功能,否則缺少這一步是無法遠程上的,這個時候我們需要安裝dconf-editor工具進行配置,
```shell
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,保持不變就行)如圖所示:
成功連接了,如圖所示: