windows宿主機ssh連接vmware ubuntu虛擬機

      網(wǎng)友投稿 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 mtu 1500 inet 10.120.50.128 netmask 255.255.255.0 broadcast 10.120.50.255 inet6 fe80::f4ef:14e:3d07:5b6b prefixlen 64 scopeid 0x20 ether 00:0c:29:a3:ba:a6 txqueuelen 1000 (以太網(wǎng)) RX packets 6447 bytes 6197333 (6.1 MB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2441 bytes 325496 (325.4 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

      記住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宿主機ssh連接vmware ubuntu虛擬機

      完成上面的步驟后,進入 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)容。

      上一篇:WPS文字如何縮小表格內(nèi)文字行間距?
      下一篇:格式在那了?(格式從哪里找)
      相關(guān)文章
      亚洲高清乱码午夜电影网| 国产91在线|亚洲| 精品久久久久亚洲| 亚洲熟妇丰满xxxxx| 亚洲AV无码一区二区三区牛牛| 亚洲人成日本在线观看| 亚洲黄色在线网站| 亚洲国产综合精品中文第一区| 国产亚洲精久久久久久无码| 亚洲女同成av人片在线观看 | 好看的电影网站亚洲一区| 亚洲一区二区三区无码中文字幕| 青青草原亚洲视频| 亚洲午夜无码久久久久| 国产精品亚洲A∨天堂不卡| 亚洲成AV人在线播放无码| 久久精品国产亚洲AV麻豆网站| 亚洲一区二区三区电影| 7777久久亚洲中文字幕蜜桃| 亚洲国产人成在线观看| 亚洲深深色噜噜狠狠网站| 亚洲精品无码中文久久字幕| 久久无码av亚洲精品色午夜| 亚洲?V乱码久久精品蜜桃 | 中文字幕亚洲一区二区va在线| 亚洲色精品88色婷婷七月丁香| 亚洲成A∨人片在线观看不卡| 亚洲精品免费观看| 亚洲国产成人在线视频| 亚洲粉嫩美白在线| 伊人久久亚洲综合影院| 国产AV无码专区亚洲AV漫画| 亚洲av片劲爆在线观看| 亚洲狠狠狠一区二区三区| 在线综合亚洲中文精品| 国产在亚洲线视频观看| 在线观看亚洲精品国产| 久久精品亚洲综合专区| 亚洲最新中文字幕| 亚洲国产成人久久一区二区三区| 亚洲精品网站在线观看不卡无广告|