Played ubuntu16 today. It is a little different from centos6.5.
The network card configuration of centos6.5 is in this directory /etc/sysconfig/network-script/ and there is one file per network card.
The network card of ubuntu16 is configured in this directory /etc/network/ and all network cards are placed in a file interfaces
The default network card name of centos6.5 is eth0, eth1
The network card name of ubuntu16 is enp0s3, enp0s8
I set up two network cards in virtualbox, one is host-only and the other is nat address translation
The network card corresponding to host-only is enp0s3, the corresponding nat is enp0s8, and lo is the default one.
After changing (vi /etc/network/interfaces):
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
car enp0s3
iface enp0s3 inet static
address 192.168.56.105
netmask 255.255.255.0
gateway 192.168.56.1
car enp0s8
iface enp0s8 inet dhcp
above
192.168.56.105 is used for communication between the virtual machine and the host.
The ip automatically assigned by enp0s8 dhcp is used for Internet access.
$ sudo /etc/init.d/networking restart (restart the network card)
ubuntu16 doesn't have iptables, so you can't edit iptables in centos like before.
#Need to open 22 port ssh by command. Or create an iptables yourself, and then start the firewall with this iptables file. The following is to open 22 port ssh through the command (the rule will disappear after restarting, it seems that it can be accessed without this rule)
iptables -A INPUT -p tcp -i eth0 --dport ssh -j ACCEPT
I found that I still can't connect with xshell, by using the command
ps -e | grep ssh
Found only ssh client but no ssh server.
So install the ssh server using the command
sudo apt-get install openssh-server
It is found that the hk.archive.ubuntu.com website cannot be connected during the installation process. I can't ping either, nor can I ping Baidu. So I thought it was a dns problem. by command
cat /etc/resolv.conf
Found to be 114.114.114.114. This ip cannot be pinged, because we access the Internet through nat mode, the virtual machine accesses the Internet through virtualbox, and virtualbox accesses the Internet through the host machine. Miss Best! Later, the mode of the network card is changed from nat network to nat address translation, and then the Internet can be accessed. As for the difference between nat network and nat address translation, no one has explained it for a long time.
Finally openssh-server is installed successfully. Connect with xshell and find that the prompt "ssh server rejected the password, once again".
day! The following is a copy of others (http://blog.csdn.net/Sky_rabbit94/article/details/52903855)
Then run the following command to see if SSH is started:
ps -e | grep ssh
If only ssh-agent indicates that it has not been started, it needs to be
/etc/init.d/ssh start。
If there is no problem with the cloud, it may be that the configuration file of ssh-server is set to deny login as root user:
Vi / etc/ssh/sshd_config
Figure 2
Change the part of Figure 2 to
Figure 3
and restart ssh-server after Figure 3
sudo /etc/init.d/ssh restore you。
If it still doesn't work, restart the virtual machine together, and it can be connected under normal circumstances.