怎么回事呀?(乳頭硬疼是怎么回事呀)
1135
2025-04-02
@[TOC]
首先獲取 windows 宿主機的 ip 地址
win + R 輸入CMD
在終端中輸入:
ipconfig
找到無線局域網(wǎng)適配器 WLAN
無線局域網(wǎng)適配器 WLAN: 連接特定的 DNS 后綴 . . . . . . . : IPv6 地址 . . . . . . . . . . . . : 2001:da8:258:d021:dd44:4c86:152b:237a 臨時 IPv6 地址. . . . . . . . . . : 2001:da8:258:d021:6da0:966e:4a06:16b8 本地鏈接 IPv6 地址. . . . . . . . : fe80::dd44:4c87:1527:237b%20 IPv4 地址 . . . . . . . . . . . . : 10.120.50.108 子網(wǎng)掩碼 . . . . . . . . . . . . : 255.254.0.0 默認網(wǎng)關(guān). . . . . . . . . . . . . : fe80::1253:72ff:fe36:2f01%20 10.120.0.1
在這里我們要記下IPv4 地址和子網(wǎng)掩碼
IPv4 地址 . . . . . . . . . . . . : 10.120.50.108 子網(wǎng)掩碼 . . . . . . . . . . . . : 255.254.0.0
配置虛擬機的虛擬網(wǎng)絡(luò)編輯器
打開VMware ,先不要打開任何一個虛擬機,進入菜單欄,點擊編輯,選擇虛擬網(wǎng)絡(luò)編輯器
點擊還原默認設(shè)置,還原之前的網(wǎng)絡(luò)設(shè)置
再次進入虛擬網(wǎng)絡(luò)編輯器中
首先點擊上部分的NAT模式類型,下圖藍色條狀那個
之前記錄的ip地址和子網(wǎng)掩碼為:
IPv4 地址 . . . . . . . . . . . . : 10.120.50.108 子網(wǎng)掩碼 . . . . . . . . . . . . : 255.254.0.0
重點:
子網(wǎng)IP應(yīng)該填寫為:10.120.50.0,最后的那個數(shù)字要為0
子網(wǎng)掩碼:255.255.255,因為填寫進去的子網(wǎng)IP是10.120.50.0,前三部分是不變的
填寫完成后,點擊確定
再打開虛擬機
查詢虛擬機的ip地址
打開虛擬機后,需要查詢虛擬機的ip地址
首先需要安裝一些軟件包:
sudo apt-get install openssh-server net-tools
安裝完成后在終端輸入:
ifconfig
我的虛擬機顯示如下:
# mrcangye @ ubuntu in /etc/ssh [23:38:21] $ ifconfig ens33: flags=4163
記住inet 10.120.50.128就是虛擬機的ip地址了
再打開虛擬網(wǎng)絡(luò)編輯器
點擊并進入NAT設(shè)置
在端口轉(zhuǎn)發(fā)處,選擇添加
主機端口和虛擬機端口填寫22即可,虛擬機IP地址輸入之前獲取的虛擬機IP地址填上去就可以了。填寫完成后一路確定就行。
配置虛擬機ssh信息
進入虛擬機,打開終端輸入以下命令進入ssh配置界面(需要會用vim編輯器)
sudo vim /etc/ssh/ssh_config
會看到:
# This is the ssh client system-wide configuration file. See # ssh_config(5) for more information. This file provides defaults for # users, and the values can be changed in per-user configuration files # or on the command line. # Configuration data is parsed as follows: # 1. command line options # 2. user-specific file # 3. system-wide file # Any configuration value is only changed the first time it is set. # Thus, host-specific definitions should be at the beginning of the # configuration file, and defaults at the end. # Site-wide defaults for some commonly used options. For a comprehensive # list of available options, their meanings and defaults, please see the # ssh_config(5) man page. Include /etc/ssh/ssh_config.d/*.conf Host * # ForwardAgent no # ForwardX11 no # ForwardX11Trusted yes PasswordAuthentication yes # HostbasedAuthentication no # GSSAPIAuthentication no # GSSAPIDelegateCredentials no # GSSAPIKeyExchange no # GSSAPITrustDNS no # BatchMode no # CheckHostIP yes # AddressFamily any # ConnectTimeout 0 # StrictHostKeyChecking ask # IdentityFile ~/.ssh/id_rsa # IdentityFile ~/.ssh/id_dsa # IdentityFile ~/.ssh/id_ecdsa # IdentityFile ~/.ssh/id_ed25519 Port 22 # Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc # MACs hmac-md5,hmac-sha1,umac-64@openssh.com # EscapeChar ~ # Tunnel no # TunnelDevice any:any # PermitLocalCommand no # VisualHostKey no # ProxyCommand ssh -q -W %h:%p gateway.example.com # RekeyLimit 1G 1h SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication yes
按下鍵盤的 i 鍵,進入 vim 的編輯模式,將 PasswordAuthentication yes 和Port 22 前的注釋取消。
修改好了后,依次按下鍵盤的esc + : + w +q 就可以保存并退出了
測試ssh連接
完成上面的步驟后,進入 windows 宿主機界面,打開終端 win + R 輸入cmd
按以下格式 ssh 連接測試是否成功
ssh 你的虛擬機用戶名@你的虛擬機IP地址
成功的話類似下面這樣
(base) PS C:\Users\mrcan> ssh mrcangye@10.120.50.128 mrcangye@10.120.50.128's password: Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.11.0-43-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage 0 updates can be applied immediately. Your Hardware Enablement Stack (HWE) is supported until April 2025. Last login: Mon Dec 20 23:38:32 2021 from 10.120.50.1 # mrcangye @ ubuntu in ~ [0:19:46] $
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。
版權(quán)聲明:本文內(nèi)容由網(wǎng)絡(luò)用戶投稿,版權(quán)歸原作者所有,本站不擁有其著作權(quán),亦不承擔(dān)相應(yīng)法律責(zé)任。如果您發(fā)現(xiàn)本站中有涉嫌抄襲或描述失實的內(nèi)容,請聯(lián)系我們jiasou666@gmail.com 處理,核實后本網(wǎng)站將在24小時內(nèi)刪除侵權(quán)內(nèi)容。