Ubuntu从设置静态IP && ssh下载启动&&关闭防火墙&&下载xshell的MD5公钥 -> 连接成功(解决Could not connect to '192.168.1.109)

一、前期检查是否修改好虚拟机的静态的IP、网关、DNS配置:

修改静态IP步骤:
1.查询网卡名称     enp0s3:
		vir@vir-VirtualBox:~$ ifconfig
		enp0s3    Link encap:Ethernet  HWaddr 08:00:27:15:61:8d  
		          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0
		          inet6 addr: fe80::9ee1:317e:63d:3801/64 Scope:Link
		          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
		          RX packets:9110 errors:0 dropped:0 overruns:0 frame:0
		          TX packets:5616 errors:0 dropped:0 overruns:0 carrier:0
		          collisions:0 txqueuelen:1000 
		          RX bytes:8922942 (8.9 MB)  TX bytes:540277 (540.2 KB)
2、修改ip配置文件   修改的网卡名称是之前查询的enp0s3:
		vir@vir-VirtualBox:~$ sudo vim  /etc/network/interfaces
		[sudo] password for vir:
		具体操作:
		auto enp0s3
		iface enp0s3inet static
		address 192.168.1.109
		netmask 255.255.255.0
		gateway 192.168.1.1
3.修改DNS解析域名IP配置
		vir@vir-VirtualBox:~$ sudo vim /etc/resolvconf/resolv.conf.d/head
		具体:采用谷歌DNS域名解析
		nameserver 8.8.8.8
4.重启网络服务:
		vir@vir-VirtualBox:~$ sudo /etc/init.d/networking restart
		得到的提示成功:
		[ ok ] Restarting networking (via systemctl): networking.service.

5.此时使用的ifconfig查看显示的是原来的IP
6.需要重启虚拟机系统 再查看就是修改后的192.168.1.109

二:进行xshell 及 ssh的相关配置:

1、 ubuntu 关闭防火墙:
		vir@vir-VirtualBox:~$ sudo ufw disable
		[sudo] password for vir: 
		Firewall stopped and disabled on system startup

2、下载ssh 服务openssh-server:

		vir@vir-VirtualBox:~$ sudo apt-get install openssh-server

		Need to get 633 kB of archives.
		After this operation, 5,136 kB of additional disk space will be used.
		Do you want to continue? [Y/n] Y
		Get:1 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213-1ubuntu1 [249 kB]
		Get:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2-4ubuntu2.6 [38.8 kB]
		Get:3 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.6 [335 kB]
		Get:4 http://cn.archive.ubuntu.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]

3、 启动 ssh 服务
		vir@vir-VirtualBox:~$ sudo service ssh start
4、 查看是否启动ssh:
		vir@vir-VirtualBox:~$ sudo ps -e | grep ssh
		 4571 ?        00:00:00 sshd
		vir@vir-VirtualBox:~$ sudo ifconfig
		enp0s3    Link encap:Ethernet  HWaddr 08:00:27:15:61:8d  
		          inet addr:192.168.1.109  Bcast:192.168.1.255  Mask:255.255.255.0
      

三、远程连接控制成功:
非寄主机:成功连接xshell:
(ssh使用的是非对称加密的方式)
连接的时候会提示下载MD5加密的公钥 还是 SHA256加密的公钥进行加密,选一个下载就可以连接成功了
Ubuntu从设置静态IP && ssh下载启动&&关闭防火墙&&下载xshell的MD5公钥 -> 连接成功(解决Could not connect to '192.168.1.109)

查看端口连接状态:
vir@vir-VirtualBox:~$ netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN     
tcp6       0      0 ::1:631                 :::*                    LISTEN     
udp        0      0 0.0.0.0:44470           0.0.0.0:*                          
udp        0      0 0.0.0.0:631             0.0.0.0:*                          
udp        0      0 0.0.0.0:5353            0.0.0.0:*                          
udp6       0      0 :::47943                :::*                               
udp6       0      0 :::5353    
查看本机DNS设置:                                       
vir@vir-VirtualBox:~$ nslookup
> server 
Default server: 8.8.8.8
Address: 8.8.8.8#53