虛擬機軟件:vmware workstation
ubantu系統鏡像: 官網 https://ubuntu.com/download/desktop
提前在d盤創建一個安裝目錄D:\linux\Ubuntu_pc_1
1、打開vmware虛擬機,點擊創建新的虛擬機
2、
3、
4、
5、
6、
7、
8、
9、
10、
11、
12、
13、
14、
15、
16、
17、注意勾選啟動時連接,否則無法啟動
18、把這三項移除
19、
20、
21、
22、
23、
24、
25、
26、
27、
28、
29、
30、此時出現如下界面
31、右擊虛擬機名稱,彈出菜單后選擇設置
32、把啟動時連接前的鈎去掉,然后點擊確定
33、然后點擊此處,選擇重新啟動客戶機
34、
35、輸入安裝時設置的密碼,回車
36、一路x掉
37、
38、右擊桌面,選擇open in terminal
39、創建root密碼
xiaoxiami@ubantupc1:~/Desktop$ sudo passwd root [sudo] password for xiaoxiami: New password: Retype new password: passwd: password updated successfully
40、切換至root用戶
iaoxiami@ubantupc1:~/Desktop$ su - root Password: root@ubantupc1:~#
41、測試網絡
oot@ubantupc1:~# ifconfig | head -n 5 Command 'ifconfig' not found, but can be installed with: apt install net-tools
42、右擊虛擬機名稱,選擇設置
43、
44、
root@ubantupc1:~# apt install net-tools Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: net-tools 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 196 kB of archives. After this operation, 864 kB of additional disk space will be used. Get:1 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
Fetched 196 kB in 6s (32.7 kB/s) Selecting previously unselected package net-tools. (Reading database ... 180241 files and directories currently installed.) Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ... Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) ... Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ... Processing triggers for man-db (2.9.1-1) ... root@ubantupc1:~# ifconfig | head -n 5 ens32: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.3.29 netmask 255.255.255.0 broadcast 192.168.3.255 inet6 fe80::f90:5d3b:be01:83d9 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:43:a9:73 txqueuelen 1000 (Ethernet) RX packets 247625 bytes 334599463 (334.5 MB)
45、測試網絡
root@ubantupc1:~# ping www.baidu.com ## 測試外網 PING www.a.shifen.com (39.156.66.18) 56(84) bytes of data. 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=1 ttl=51 time=13.3 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=2 ttl=51 time=13.4 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=3 ttl=51 time=13.1 ms 64 bytes from 39.156.66.18 (39.156.66.18): icmp_seq=4 ttl=51 time=13.4 ms ^C --- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 6021ms rtt min/avg/max/mdev = 13.116/13.296/13.409/0.110 ms
root@ubantupc1:~# ping 192.168.3.4 ## 測試本地物理機 PING 192.168.3.4 (192.168.3.4) 56(84) bytes of data. 64 bytes from 192.168.3.4: icmp_seq=1 ttl=128 time=0.179 ms 64 bytes from 192.168.3.4: icmp_seq=2 ttl=128 time=0.189 ms 64 bytes from 192.168.3.4: icmp_seq=3 ttl=128 time=0.177 ms 64 bytes from 192.168.3.4: icmp_seq=4 ttl=128 time=0.164 ms 64 bytes from 192.168.3.4: icmp_seq=5 ttl=128 time=0.187 ms ^C --- 192.168.3.4 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4103ms rtt min/avg/max/mdev = 0.164/0.179/0.189/0.008 ms
C:\Users\75377>ping 192.168.3.29 ## 物理機ping 虛擬機 正在 Ping 192.168.3.29 具有 32 字節的數據: 來自 192.168.3.29 的回復: 字節=32 時間<1ms TTL=64 來自 192.168.3.29 的回復: 字節=32 時間<1ms TTL=64 來自 192.168.3.29 的回復: 字節=32 時間<1ms TTL=64 來自 192.168.3.29 的回復: 字節=32 時間<1ms TTL=64
192.168.3.29 的 Ping 統計信息: 數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失), 往返行程的估計時間(以毫秒為單位): 最短 = 0ms,最長 = 0ms,平均 = 0ms
46、安裝ssh服務
root@ubantupc1:~# apt-get install openssh-server Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: ncurses-term openssh-sftp-server ssh-import-id Suggested packages: molly-guard monkeysphere ssh-askpass The following NEW packages will be installed: ncurses-term openssh-server openssh-sftp-server ssh-import-id 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 688 kB of archives. After this operation, 6,010 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 ncurses-term all 6.2-0ubuntu2 [249 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-sftp-server amd64 1:8.2p1-4ubuntu0.1 [51.5 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu focal-updates/main amd64 openssh-server amd64 1:8.2p1-4ubuntu0.1 [377 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu focal/main amd64 ssh-import-id all 5.10-0ubuntu1 [10.0 kB]
Fetched 688 kB in 14s (48.4 kB/s) Preconfiguring packages ... Selecting previously unselected package ncurses-term. (Reading database ... 180290 files and directories currently installed.) Preparing to unpack .../ncurses-term_6.2-0ubuntu2_all.deb ... Unpacking ncurses-term (6.2-0ubuntu2) ... Selecting previously unselected package openssh-sftp-server. Preparing to unpack .../openssh-sftp-server_1%3a8.2p1-4ubuntu0.1_amd64.deb ... Unpacking openssh-sftp-server (1:8.2p1-4ubuntu0.1) ... Selecting previously unselected package openssh-server. Preparing to unpack .../openssh-server_1%3a8.2p1-4ubuntu0.1_amd64.deb ... Unpacking openssh-server (1:8.2p1-4ubuntu0.1) ... Selecting previously unselected package ssh-import-id. Preparing to unpack .../ssh-import-id_5.10-0ubuntu1_all.deb ... Unpacking ssh-import-id (5.10-0ubuntu1) ... Setting up openssh-sftp-server (1:8.2p1-4ubuntu0.1) ... Setting up openssh-server (1:8.2p1-4ubuntu0.1) ... Creating config file /etc/ssh/sshd_config with new version Creating SSH2 RSA key; this may take some time ... 3072 SHA256:5csmtxdqgRivQ2lVtl9dIIFhAoTde/ahVtbflkrTqbM root@ubantupc1 (RSA) Creating SSH2 ECDSA key; this may take some time ... 256 SHA256:QSvBl91xiQwryrFI2iFwxyPn4hCy5p+2s6qJYSFEpS0 root@ubantupc1 (ECDSA) Creating SSH2 ED25519 key; this may take some time ... 256 SHA256:9EhHVJd2x/ZKcZn637cOABoHe2net5PX8LRApkPDiOQ root@ubantupc1 (ED25519) Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service. Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service. rescue-ssh.target is a disabled or a static unit, not starting it. Setting up ssh-import-id (5.10-0ubuntu1) ... Attempting to convert /etc/ssh/ssh_import_id Setting up ncurses-term (6.2-0ubuntu2) ... Processing triggers for systemd (245.4-4ubuntu3.3) ... Processing triggers for man-db (2.9.1-1) ... Processing triggers for ufw (0.36-6) ...
47、ssh登錄測試
完成。