你看照片能不能看得清楚
主要是從11-1-4開始
然後到11-2-2 跨主機複製檔案
因為要弄跨主機,所以要多再製一個虛擬機
原本的那台,網路設定,多勾一個介面卡2(host only)
多加的那台,勾一個host only就好
課堂上的練習主要是使用ssh登入另一台主機,試複製檔案之類的東西
一般的ssh在登入時會要求輸入帳密
多開的作業是透過使用 keygen 來生成金鑰(?) 然後複製回來,讓之後再ssh不用再重複輸入帳密
大概是這樣,不過我自己目前只有試到可以互相ssh,但是keygen後複製回來後還沒成功讓他不用再輸入帳密
- 再製一台機器
- 原本的機器網路增加一個介面卡,設定為 Host only
- 再製的機器將原本的介面卡設定為 Host only
- 備註
- 此時的電腦仍能連上 Internet,但再製的機器不行,可是兩台機器間能夠互連(能夠互相 Ping 到對方)
- Host only 模式下 IP 皆為 192.168.56 開頭
- 在筆者環境下,主機 IP 為 192.168.56.101;再製為 192.168.56.102(可透過
ifconfig
查詢)
- 各種模式差異可參考上學期
W2 20180305.md
筆記內容
- 記得雙方都需要先開啟 ssh(注意需有 Root 權限)
[user@localhost ~]$ systemctl start sshd
Failed to issue method call: Access denied
[user@localhost ~]$ sudo systemctl start sshd
[user@localhost ~]$ sudo netstat -anp | grep sshd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2804/sshd
tcp6 0 0 :::22 :::* LISTEN 2804/sshd
unix 3 [ ] STREAM CONNECTED 24986 2804/sshd
- 注意:如果有一方未開啟 ssh,可能會跳出以下錯誤訊息
[user@localhost ~]$ sudo ssh user@192.168.56.102
ssh: connect to host 192.168.56.102 port 22: Connection refused
- 如果見到以下訊息,代表正確連接
- 需要確認是否連接與詢問對方的密碼
[user@localhost ~]$ sudo ssh user@192.168.56.102
The authenticity of host '192.168.56.102 (192.168.56.102)' can't be established.
ECDSA key fingerprint is 6e:74:ef:33:9e:99:c2:61:b6:30:d1:27:c0:88:e9:30.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.56.102' (ECDSA) to the list of known hosts.
user@192.168.56.102's password:
Last login: Tue Oct 2 03:12:26 2018
- 由於兩台主機的使用者名稱相同,因此可查看
ifconfig
中的 IP 來辨別(如以下 IP 為再製的 192.168.56.102
)
[user@localhost ~]$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.56.102 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::a00:27ff:fef4:7f43 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:f4:7f:43 txqueuelen 1000 (Ethernet)
RX packets 100 bytes 16725 (16.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 115 bytes 17115 (16.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 0 (Local Loopback)
RX packets 12 bytes 820 (820.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12 bytes 820 (820.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[user@localhost ~]$ exit
logout
Connection to 192.168.56.102 closed.