登录来宾 Linux VirtualBox VM 的最佳方式是端口转发。默认情况下,您应该已经有一个使用 NAT 的接口。然后转到“网络”设置并单击“端口转发”按钮。添加新的规则。作为规则名称,插入“ssh”。作为“主机端口”,插入 3022。作为“访客端口”,插入 22。规则的其他所有内容都可以留空。
The best way to login to a guest Linux VirtualBox VM is port forwarding. By default, you should have one interface already which is using NAT. Then go to the Network settings and click the Port Forwarding button. Add a new Rule. As the rule name, insert "ssh". As "Host port", insert 3022. As "Guest port", insert 22. Everything else of the rule can be left blank.
Change the adapter type in VirtualBox to bridged, and set the guest to use DHCP or set a static IP address outside of the bounds of DHCP. This will cause the Virtual Machine to act like a normal guest on your home network. You can then port forward.
Remember to create a host-only network in virtualbox itself (GUI -> settings -> network), otherwise you can't create the host-only interface on the guest.
You can also use a Bridged Network (or "Bridge Adapter", in newer versions) in network settings. This will put your VM in a VLAN with your machine. So you can just ssh into the VM like this.
LINUX测试以查看是否ssh服务器运行 w/命令: sudo service ssh status
可以检查 netstat 以查看是否已连接到来宾计算机上的端口 22
此外,根据使用的平台,还有不同的 ssh 服务器和客户端。
wikipedia/Secure_Shell
wikipedia/Comparison_of_SSH_servers
wikipedia/Comparison_of_SSH_clients
对于 Ubuntu 用户:
ubuntu 社区:SSHOpenSSH/Configuring
ubuntu/community: OpenSSH/Keys
应该就是这样了。如果我犯了错误或想添加任何内容 - 请随意这样做 - 我仍然是一个菜鸟。
希望这对某人有帮助。祝你好运!
SSH Back to Your Home / Office VirtualBox Guest Machine From The INTERNET
The answers provided by other users here : How to SSH to a VirtualBox guest externally through a host?
... helped me to accomplish the task of connecting from out on the internet to my home computer's guest machine. You should be able to connect using computers, tablets, and smart phones (android, IPhone,etc). I add a few more step in case it might be helpful to someone else:
Here is a quick diagram of my setup:
Remote device ---> INTERNET --> MODEM --> ROUTER --> HOST MACHINE --> GUEST VM
Remote device (leave ssh port 3022) ---> INTERNET --> MODEM --> ROUTER (FWD frm:p3022 to:p3022)--> HOST MACHINE (FWD frm:p3022 to:p22) --> GUEST VM (arrive ssh port 22)
The key for me was to realize that ALL connections was PASSING-THROUGH intermediary devices to get from my remote PC to my guest virtual-machine at home --Hence port forwarding!
Notes:
* Need ssh client to request a secure connection and a running ssh server to process the secure connection.
I will forward the port 3022 as used in the chosen answer from above.
Enter your IPs where needed (home modem/router, host IP, guest IP,etc.), Names chosen are just examples-use or change.
1.Create ssh tunnel to port 3022 on your modem's IP / router's external IP address.
ssh client/device possible commands: ssh -p 3022 user-name@home_external_IP
2.Port forward = we are passing thru the connection from router to host machine
Also make sure firewall /IPtable rules on router is allowing ports to be forward (open if needed)
Router's Pfwd SCREEN required entries: AppName:SSH_Fwd, Port_from: 3022, Protocol:both (UDP/TCP), IP_address:hostIP_address, Port_to:3022, everything else can be blank
3.Host Machine Firewall: open port 3022 #so forwarded port can pass thru to guest machine
Host Machine: Install VirtualBox, guest additions, and guest machine if not done already
Configure guest machine and then follow the Network section below
I used VirtualBox GUI to setup guest's network- easier than CLI
If you want to use other methods refer to : VirtualBox/manual/ch06.html#natforward
4.Some suggest using Network Bridge adapter for guest = access to LAN and other machines on your LAN. This also pose an increase security risk, because now your guest machine is now exposed to LAN machines and possibly the INTERNET hackers if firewall not setup properly. So I selected Network adapter attached to NAT for less exposure to bridged security risks.
On the guest machine do the following:
Guest Machine VirtualBox Network settings: Adapter 1: Attached to NAT
Guest Machine VirtualBox Port Forwarding Rule: Name:External_SSH, Protocol:TCP, Host Port: 3022, Guest Port 22, Host&guest IPs:leave blank
click on advance in Network section then click on Port forwarding to enter rules
Guest Machine Firewall: open port 22 #so ssh connection can enter
Guest Machine: Make sure that ssh server is installed, configured properly, and running
LINUX test to see if ssh server running w/command: sudo service ssh status
Can check netstat to see if connection made to port 22 on the guest machine
Also there are different ssh servers and clients depending on platform using.
wikipedia/Secure_Shell
wikipedia/Comparison_of_SSH_servers
wikipedia/Comparison_of_SSH_clients
For Ubuntu Users:
ubuntu community: SSHOpenSSH/Configuring
ubuntu/community: OpenSSH/Keys
That should be it. If I made a mistake or want to add anything -feel free to do so-- I am still a noob.
You can also initiate a port forward TO your HOST, OR ANY OTHER SERVER, from your Guest. This is especially useful if your Guest is 'locked' or can't otherwise complete the ModifyVM option (e.g. no permission to VBoxManage).
Three minor requirements are 1) you are/can log into the VirtualBox Guest (via 'console' GUI, another Guest, etc), 2) you have an account on the VirtualBox HOST (or other Server), and 3) SSH and TCP forwarding is not blocked.
Presuming you can meet the 3 requirements, these are the steps:
On the Guest, run netstat -rn and find the Gateway address to the default route destination 0.0.0.0. Let's say it's "10.0.2.2". This 'Gateway' address is (one of) the VirtualBox Host virtual IP(s).
On the Guest, run ssh -R 2222:localhost:22 10.0.2.2 where "10.0.2.2" is the VirtualBox server's IP address -OR- any other server IP you wish to port forward to.
On the Host, run ssh 10.0.2.2 -p2222 where 10.0.2.2 is the default gateway/VBHost virtual IP found in step 1. If it is NOT the VirtualBox host you are port forwarding to, then the command is ssh localhost -p2222
network:
ethernets:
enp0s3:
addresses: []
dhcp4: true
enp0s8:
addresses: [192.168.0.200/24]
dhcp4: no
dhcp6: no
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
version: 2
对您有帮助的命令
nano /etc/netplan/file.yaml # file to specify the rules of network
reboot now # restart ubuntu server right now
netplan apply # do after edited *.yaml, to apply changes
ifconfig -a # show interfaces with ip, netmask, broadcast, etc...
ping google.com # to see if there is internet
Configuration with bridged to see the server ip, and connect without "port forwarding"
VirtualBox > right click in server > settings > Network > enable adapter 2 > select "bridged" > Promiscuous mode: allow all > Check the cable connected > start server
On ubuntu server, edit sudo nano /etc/netplan/*init.yaml file,
My sample file:
network:
ethernets:
enp0s3:
addresses: []
dhcp4: true
enp0s8:
addresses: [192.168.0.200/24]
dhcp4: no
dhcp6: no
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
version: 2
Commands that will help you
nano /etc/netplan/file.yaml # file to specify the rules of network
reboot now # restart ubuntu server right now
netplan apply # do after edited *.yaml, to apply changes
ifconfig -a # show interfaces with ip, netmask, broadcast, etc...
ping google.com # to see if there is internet
当您执行此操作时,您的 IP 将发生变化。然而,就我而言,它并没有立即改变。 ifconfig 返回相同的 IP。我重新启动了虚拟机,然后将 IP 设置为以 192.* 开头,并且立即允许我进行 ssh 访问。
Simply setting the Network Setting to bridged did the trick for me.
Your IP will change when you do this. However, in my case it didn't change immediately. ifconfig returned the same ip. I rebooted the vm and boom, the ip set itself to one start with 192.* and I was immediately allowed ssh access.
On secure networks setting your network to bridge might not work. Administrators could only allow one mac address per port or even worse block the port should the switches detect multiple macs on one port.
The best solution in my opinion is to set up additional network interfaces to handle additional services you would like to run on your machines. So I have a bridge interface to allow for bridging when I take my laptop home and can SSH into it from other devices on my network as well as a host only adapter when I would like to SSH into my VM from my laptop when I am connected to the eduroam wifi network on campus.
发布评论
评论(15)
登录来宾 Linux VirtualBox VM 的最佳方式是端口转发。默认情况下,您应该已经有一个使用 NAT 的接口。然后转到“网络”设置并单击“端口转发”按钮。添加新的规则。作为规则名称,插入“ssh”。作为“主机端口”,插入 3022。作为“访客端口”,插入 22。规则的其他所有内容都可以留空。
或从命令行
,其中“myserver”是创建的虚拟机的名称。检查添加的规则:
仅此而已!请确保您不要忘记在虚拟机中安装 SSH 服务器:
通过 SSH 进入来宾 VM,写入:
其中
user
是您在 VM 中的用户名。The best way to login to a guest Linux VirtualBox VM is port forwarding. By default, you should have one interface already which is using NAT. Then go to the Network settings and click the Port Forwarding button. Add a new Rule. As the rule name, insert "ssh". As "Host port", insert 3022. As "Guest port", insert 22. Everything else of the rule can be left blank.
or from the command line
where 'myserver' is the name of the created VM. Check the added rules:
That's all! Please be sure you don't forget to install an SSH server in the VM:
To SSH into the guest VM, write:
Where
user
is your username within the VM.将 VirtualBox 中的适配器类型更改为桥接,并将来宾设置为使用 DHCP 或设置静态 < a href="http://en.wikipedia.org/wiki/IP_address" rel="noreferrer">IP 地址 超出 DHCP 范围。这将使虚拟机像家庭网络上的普通访客一样工作。然后您可以转发。
Change the adapter type in VirtualBox to bridged, and set the guest to use DHCP or set a static IP address outside of the bounds of DHCP. This will cause the Virtual Machine to act like a normal guest on your home network. You can then port forward.
保留 NAT 适配器并添加第二个仅主机适配器效果惊人,并且对于笔记本电脑(外部网络总是发生变化)至关重要。
http://muffinresearch。 co.uk/archives/2010/02/08/howto-ssh-into-virtualbox-3-linux-guests/
记住创建virtualbox 本身中的仅主机网络(GUI -> 设置 -> 网络),否则您无法在来宾上创建仅主机接口。
Keeping the NAT adapter and adding a second host-only adapter works amazing, and is crucial for laptops (where the external network always changes).
http://muffinresearch.co.uk/archives/2010/02/08/howto-ssh-into-virtualbox-3-linux-guests/
Remember to create a host-only network in virtualbox itself (GUI -> settings -> network), otherwise you can't create the host-only interface on the guest.
您还可以在网络设置中使用桥接网络(或较新版本中的“桥接适配器”)。这会将您的虚拟机与您的计算机置于一个 VLAN 中。所以你可以像这样通过 ssh 进入虚拟机。
You can also use a Bridged Network (or "Bridge Adapter", in newer versions) in network settings. This will put your VM in a VLAN with your machine. So you can just ssh into the VM like this.
如何为 Solaris 10 和 Ubuntu 16.04 创建仅主机网络(比桥接更好)
添加仅主机接口
启动 cmd.exe 并运行
ipconfig /all
。您应该看到以下几行:来宾中的第二个适配器也应位于 192.168.59.*。
启动虚拟机。
Solaris 10
ifconfig -一个。您应该看到 e1000g0 和 e1000g1。我们对 e1000g1 感兴趣。
ifconfig e1000g down
ifconfig e1000g 192.168.56.10 netmask 255.255.255.0 up
ping 192.168.56.10
保留这些设置重新启动后
配置 ssh 服务 (管理)以root身份登录(不建议)
检查是否启用了ssh
修改/etc/ssh/sshd_config以便有
重新启动ssh服务
从主机检查
Ubuntu 16.04
列表接口:
你应该看到三个接口,如 lo、enp0s3、enp0s8。我们将使用第三个。
编辑 /etc/network/interfaces
然后
sudo ifup enp0s8
。检查 enp0s8 是否获得正确的地址。您应该看到您的 IP:如果没有,您可以运行 sudo ifdown enp0s8 && sudo ifup enp0s8
https://superuser.com/questions/424083 /virtualbox-host-ssh-to-guest/424115#424115
How to do host-only network (better than bridged) for Solaris 10 and Ubuntu 16.04
Add Host-only interface
Start cmd.exe and run
ipconfig /all
. You should see lines:Second adapter in guest should also be in 192.168.59.*.
Start VM.
Solaris 10
ifconfig -a
. You should see e1000g0 and e1000g1. We are interested in e1000g1.ifconfig e1000g down
ifconfig e1000g 192.168.56.10 netmask 255.255.255.0 up
ping 192.168.56.10
Preserve those settings upon reboot
Configure ssh service (administering) to login as root (not adviced)
Check if ssh is enabled
Modify /etc/ssh/sshd_config so there is
Restart ssh service
From host check it
Ubuntu 16.04
List interfaces:
You should see three interfaces like lo, enp0s3, enp0s8. We will use the third.
Edit /etc/network/interfaces
Then
sudo ifup enp0s8
. Check if enp0s8 got correct address. You should see your ip:If not, you may run
sudo ifdown enp0s8 && sudo ifup enp0s8
https://superuser.com/questions/424083/virtualbox-host-ssh-to-guest/424115#424115
为了从主机通过 ssh 连接到 VirtualBox 中运行的 Ubuntu 虚拟机,您需要为虚拟机设置两个网络适配器。
首先,如果尚未停止,请停止虚拟机。
然后选择虚拟机并单击 VirtualBox 工具栏中的“设置”菜单:
设置适配器 1
<图片src="https://i.sstatic.net/63znz.png" alt="在此处输入图像描述">
设置适配器 2
(注意:您不需要设置任何端口转发。)
就是这样。设置完成后,您就可以启动虚拟机了。在您的虚拟机中,网络配置如下所示,并且您也可以访问 Internet:
另外,在您的主机中,您可以 ssh 到您的虚拟机:
确保 SSH 服务器已安装并在 VM 中运行。
如果没有,请安装它:
另外供您参考:
In order to ssh to a Ubuntu VM running in VirtualBox from your host machine, you need to set up two network adapters for the VM.
First of all, stop the VM if not yet.
Then select the VM and click the Settings menu in the VirtualBox toolbar:
Set up Adapter 1
Set up Adapter 2
(Note: you don't need to set up any port forwarding.)
That's it. Once set up, you can start your VM. In your VM, the network configuration will look like below and you'll have Internet access too:
Also in your host machine, you can ssh to your VM:
Be sure that the SSH server has been installed and up running in the VM.
If not, install it:
Also for your information:
SSH Back to Your Home / Office VirtualBox Guest Machine From The INTERNET
其他用户在这里提供的答案:
如何通过主机从外部通过 SSH 连接到 VirtualBox 来宾?
...帮助我完成了从互联网上连接到我家用计算机的来宾计算机的任务。您应该能够使用计算机、平板电脑和智能手机(Android、iPhone 等)进行连接。我添加了更多步骤,以防对其他人有帮助:
这是我的设置的快速图表:
远程设备 --->互联网 -->调制解调器 -->路由器-->主机 -->来宾虚拟机
远程设备(ssh 客户端)--->直通设备 ---> GUEST VM(ssh 服务器)
远程设备(保留 ssh 端口 3022)--->互联网 -->调制解调器 -->路由器(转发从:p3022 到:p3022)-->主机(转发从:p3022 到:p22) -->访客虚拟机(到达 ssh 端口 22)
对我来说,关键是要认识到所有连接都是从远程 PC 到家中的来宾虚拟机的
直通
中间设备 - -因此端口转发!笔记:
* 需要 ssh 客户端来请求安全连接,并需要一个正在运行的 ssh 服务器来处理安全连接。
我将转发上面所选答案中使用的端口 3022。
在需要的地方输入您的 IP(家庭调制解调器/路由器、主机 IP、访客 IP 等),选择的名称只是示例 - 使用或更改。
1. 在调制解调器的 IP/路由器的外部 IP 地址上创建到端口 3022 的 ssh 隧道。
ssh 客户端/设备可能的命令:ssh -p 3022 user-name@home_external_IP
2.端口转发 = 我们通过从路由器到主机的连接
同时确保防火墙/IPtable 规则打开路由器允许端口转发(如果需要打开)
路由器的 Pfwd SCREEN 所需条目:AppName:SSH_Fwd、Port_from :3022,协议:both (UDP/TCP),IP_address:hostIP_address,Port_to:3022,其他一切都可以为空
DD-WRT 路由器软件资源 / Info:
DD-WRT Port_Forwarding
DD-WRT 静态_DHCP
3.主机防火墙:打开端口 3022 #so 转发的端口可以传递到来宾计算机
主机:安装 VirtualBox、来宾添加项和来宾计算机(如果尚未完成)
配置来宾计算机,然后按照下面的网络部分进行操作
我使用 VirtualBox GUI 来设置来宾网络 - 比 CLI 更容易
如果您想使用其他方法,请参阅:
VirtualBox/manual/ch06.html#natforward
4.有些人建议使用网桥适配器来访问 LAN 和 LAN 上的其他计算机。这也会增加安全风险,因为现在您的来宾计算机现在暴露于 LAN 计算机,如果防火墙设置不正确,还可能暴露于 INTERNET 黑客。因此,我选择连接到 NAT 的网络适配器,以减少桥接安全风险。
在来宾计算机上执行以下操作:
此外,根据使用的平台,还有不同的 ssh 服务器和客户端。
wikipedia/Secure_Shell
wikipedia/Comparison_of_SSH_servers
wikipedia/Comparison_of_SSH_clients
对于 Ubuntu 用户:
ubuntu 社区:SSHOpenSSH/Configuring
ubuntu/community: OpenSSH/Keys
应该就是这样了。如果我犯了错误或想添加任何内容 - 请随意这样做 - 我仍然是一个菜鸟。
希望这对某人有帮助。祝你好运!
SSH Back to Your Home / Office VirtualBox Guest Machine From The INTERNET
The answers provided by other users here :
How to SSH to a VirtualBox guest externally through a host?
... helped me to accomplish the task of connecting from out on the internet to my home computer's guest machine. You should be able to connect using computers, tablets, and smart phones (android, IPhone,etc). I add a few more step in case it might be helpful to someone else:
Here is a quick diagram of my setup:
Remote device ---> INTERNET --> MODEM --> ROUTER --> HOST MACHINE --> GUEST VM
Remote device (ssh client) ---> PASS THRU DEVICES ---> GUEST VM (ssh server)
Remote device (leave ssh port 3022) ---> INTERNET --> MODEM --> ROUTER (FWD frm:p3022 to:p3022)--> HOST MACHINE (FWD frm:p3022 to:p22) --> GUEST VM (arrive ssh port 22)
The key for me was to realize that ALL connections was
PASSING-THROUGH
intermediary devices to get from my remote PC to my guest virtual-machine at home --Hence port forwarding!Notes:
* Need ssh client to request a secure connection and a running ssh server to process the secure connection.
I will forward the port 3022 as used in the chosen answer from above.
Enter your IPs where needed (home modem/router, host IP, guest IP,etc.), Names chosen are just examples-use or change.
1.Create ssh tunnel to port 3022 on your modem's IP / router's external IP address.
ssh client/device possible commands: ssh -p 3022 user-name@home_external_IP
2.Port forward = we are passing thru the connection from router to host machine
Also make sure firewall /IPtable rules on router is allowing ports to be forward (open if needed)
Router's Pfwd SCREEN required entries: AppName:SSH_Fwd, Port_from: 3022, Protocol:both (UDP/TCP), IP_address:hostIP_address, Port_to:3022, everything else can be blank
DD-WRT router software resources / Info:
DD-WRT Port_Forwarding
DD-WRT Static_DHCP
3.Host Machine Firewall: open port 3022 #so forwarded port can pass thru to guest machine
Host Machine: Install VirtualBox, guest additions, and guest machine if not done already
Configure guest machine and then follow the Network section below
I used VirtualBox GUI to setup guest's network- easier than CLI
If you want to use other methods refer to :
VirtualBox/manual/ch06.html#natforward
4.Some suggest using Network Bridge adapter for guest = access to LAN and other machines on your LAN. This also pose an increase security risk, because now your guest machine is now exposed to LAN machines and possibly the INTERNET hackers if firewall not setup properly. So I selected Network adapter attached to NAT for less exposure to bridged security risks.
On the guest machine do the following:
Also there are different ssh servers and clients depending on platform using.
wikipedia/Secure_Shell
wikipedia/Comparison_of_SSH_servers
wikipedia/Comparison_of_SSH_clients
For Ubuntu Users:
ubuntu community: SSHOpenSSH/Configuring
ubuntu/community: OpenSSH/Keys
That should be it. If I made a mistake or want to add anything -feel free to do so-- I am still a noob.
Hope this helps someone. Good luck!
对于 Windows 主机,您可以:
For Windows host, you can :
您还可以从您的访客启动端口转发到您的主机或任何其他服务器。如果您的来宾被“锁定”或无法以其他方式完成ModifyVM 选项(例如没有VBoxManage 的权限),这尤其有用。
三个次要要求是 1) 您可以登录 VirtualBox Guest(通过“控制台”GUI、另一个 Guest 等),2) 您在 VirtualBox HOST(或其他服务器)上有一个帐户,以及 3) SSH 和 TCP转发不会被阻止。
假设您可以满足 3 个要求,步骤如下:
netstat -rn
并找到默认路由目标 0.0.0.0 的网关地址。假设它是“10.0.2.2”。此“网关”地址是 VirtualBox 主机虚拟 IP(其中之一)。You can also initiate a port forward TO your HOST, OR ANY OTHER SERVER, from your Guest. This is especially useful if your Guest is 'locked' or can't otherwise complete the ModifyVM option (e.g. no permission to VBoxManage).
Three minor requirements are 1) you are/can log into the VirtualBox Guest (via 'console' GUI, another Guest, etc), 2) you have an account on the VirtualBox HOST (or other Server), and 3) SSH and TCP forwarding is not blocked.
Presuming you can meet the 3 requirements, these are the steps:
netstat -rn
and find the Gateway address to the default route destination 0.0.0.0. Let's say it's "10.0.2.2". This 'Gateway' address is (one of) the VirtualBox Host virtual IP(s).ssh -R 2222:localhost:22 10.0.2.2
where "10.0.2.2" is the VirtualBox server's IP address -OR- any other server IP you wish to port forward to.ssh 10.0.2.2 -p2222
where 10.0.2.2 is the default gateway/VBHost virtual IP found in step 1. If it is NOT the VirtualBox host you are port forwarding to, then the command isssh localhost -p2222
按照以下步骤使用 putty 从主机登录到在 Virtual Box 中运行的 ubuntu 虚拟机(无需端口转发):
在 Virtualbox 管理器上选择虚拟机,单击设置图标。然后转到网络并启用两个适配器,如下所示:
启动 ubuntu 虚拟机。
如下编辑文件“/etc/network/interfaces”并保存:
重新启动虚拟机。
登录虚拟机并运行以下命令来检查分配给 eth1 的 IP:
<前><代码>ifconfig
使用此 IP 为虚拟机打开 putty 会话。
Follow below steps to login to your ubuntu VM running in virtual box from the host machine using putty (Without port forwarding):
On Virtualbox manager select the vm, click on settings icon. Then go Networks and enable two adaptors as below:
Start the ubuntu vm.
Edit the file '/etc/network/interfaces' as below and save it:
Restart the VM.
Login to the VM and run below command to check the IP allocated to eth1:
Use this IP to open putty session for the VM.
关于如何使用 NAT 配置端口转发的详细说明可以在 VirtualBox 文档中找到:
http://www.virtualbox.org/manual/ch06.html#natforward
A good explanation about how to configure port forwarding with NAT is found in the VirtualBox documents:
http://www.virtualbox.org/manual/ch06.html#natforward
Ubuntu 18.04 LTS
配置桥接以查看服务器 IP,并在没有“端口转发”的情况下连接
VirtualBox >右键单击服务器>设置>网络>启用适配器 2 >选择“桥接”>混杂模式:允许所有>检查电缆连接>启动服务器
在ubuntu服务器上,编辑
sudo nano /etc/netplan/*init.yaml
文件,我的示例文件:
对您有帮助的命令
在 Ubuntu 上配置静态 IP 地址18.04 LTS 服务器 - 使用 NetPlan
Ubuntu 18.04 LTS
Configuration with bridged to see the server ip, and connect without "port forwarding"
VirtualBox > right click in server > settings > Network > enable adapter 2 > select "bridged" > Promiscuous mode: allow all > Check the cable connected > start server
On ubuntu server, edit
sudo nano /etc/netplan/*init.yaml
file,My sample file:
Commands that will help you
Configure Static IP Addresses On Ubuntu 18.04 LTS Server - with NetPlan
只需将网络设置设置为桥接就可以了。
当您执行此操作时,您的 IP 将发生变化。然而,就我而言,它并没有立即改变。
ifconfig
返回相同的 IP。我重新启动了虚拟机,然后将 IP 设置为以 192.* 开头,并且立即允许我进行 ssh 访问。Simply setting the Network Setting to bridged did the trick for me.
Your IP will change when you do this. However, in my case it didn't change immediately.
ifconfig
returned the same ip. I rebooted the vm and boom, the ip set itself to one start with 192.* and I was immediately allowed ssh access.在安全网络上,将网络设置为桥接可能不起作用。管理员只能允许每个端口使用一个 MAC 地址,如果交换机在一个端口上检测到多个 MAC 地址,管理员甚至可以阻止该端口。
我认为最好的解决方案是设置额外的网络接口来处理您想要在计算机上运行的额外服务。因此,当我将笔记本电脑带回家时,我有一个桥接接口,可以进行桥接,并且可以从网络上的其他设备通过 SSH 进入它,并且当我想在连接时从我的笔记本电脑通过 SSH 进入我的虚拟机时,我有一个仅主机适配器连接到校园内的 eduroam wifi 网络。
On secure networks setting your network to bridge might not work. Administrators could only allow one mac address per port or even worse block the port should the switches detect multiple macs on one port.
The best solution in my opinion is to set up additional network interfaces to handle additional services you would like to run on your machines. So I have a bridge interface to allow for bridging when I take my laptop home and can SSH into it from other devices on my network as well as a host only adapter when I would like to SSH into my VM from my laptop when I am connected to the eduroam wifi network on campus.
使用 NAT 网络适配器并添加端口转发。提及实际主机 IP。不要使用 127.0.0.1 或 localhost。
Use NAT network adapter and Add port forward. Mention actual host ip.Do not use 127.0.0.1 or localhost.