1,Xshell6连接到虚拟机上
设置静态IP,(不设置静态连接,每次进来都需要连接很是麻烦,因此我们设置为静态连接)
此篇是坑,还没完成,有时间再来,建议别看。过了半个月我又来试试,什么都没做。就选择了ssh登陆就连上了。
查看子网IP,你需要记住子网IP
设置linux系统中的静态IP,进入Linux系统,右键open termial运行如下命令
首先你得进入root权限:首次登陆设置root密码(不用担心没有输入进去,这Linux下的特点,光标不会移动,但是内容是有的)
进入root权限下:(简单判断)
su命令的作用就是用来进行切换用户的。
udo命令的作用就是让授权的普通用户能够以管理员权限执行命令。
若使用具有管理员权限的用户登录时,将出现/#符号
若使用不具有管理员权限的用户登录时,将出现/$符号
2、过程:用root用户执行了"root@ubuntu:~# find / -name “enetwork-scripts” " 在返回的执行结果中第一行就是显示“find: ‘/run/user/1000/gvfs’: Permission denied”。
原因:官方说这是一个bug——bug#615848. 原因是FUSE文件系统和权限不配的问题,全局搜索时碰到它就会退出报错。顺带跑到目录/run/user/1000/下面查看了下权限,发现出了第一位是d表示gvfs是个目录外,其他表示权限的9位全部是问号。
其实这个目录是空的,所以删除就好了执行下列操作:
umount /run/user/1000/gvfs
rm -rf /run/user/1000/gvfs
之后的查找中就没有了报错提示。
CentOS7系统安装完毕之后,输入ifconfig命令发现没有eth0,不符合我们的习惯。而且也无法远程ssh连接
需要将ens33改为eth0
这里解释下:ens33和eth0
eno1:代表由主板bios内置的网卡
ens1:代表有主板bios内置的PCI-E网卡
enp2s0: PCI-E独立网卡
eth0:如果以上都不使用,则回到默认的网卡名(这是静态获取)
ens33则属于第二种类型,即说明你的网卡是内置的PCI-E网卡(这是动态获取)
eth0是真实物理网卡,ens33是虚拟网络会话。
话说Debian系的网卡配置跟Redhat系很不一样,Redhat是放在/etc/sysconfig/network-scripts目录下面的一大堆文件里面,要修改?你一个一个文件来过吧。Debian系的则是存在/etc/network/interfaces文件里面,无论有多少块网卡,统统扔在这个文件里。
如上面所示,并没有传统上的:/etc/sysconfig/network-scripts/。关于这个配置网上版本很多。
如果你确定你的/etc/下没有sysconfig文件夹,那么你应该装的不是rh linux,有可能是其他版本的linux,例如ubuntu。
那你看看/etc/下面有没有一个networks目录。看看有没有一个文件叫做interfaces.如果有就在这里面配置
接着摸爬滚打。。。。在前面我找到了/etc/network/interfaces,但是无法更改。于是从头查错,发现我忽略了的一个大错。如下:最开始我以为这不是错,只是警告?????
需要改为使用镜像文件连接(修改之后便不会在提示)
确实连上去了,但是不能上网,于是在dos上查看电脑上的IP(需要去查看控制面板\网络和 Internet\网络连接是否有默认的VMnet0和VMnet8)。如下是否有对应的配置。
实验ping www.baidu.com。能成功。
那么就只剩下一个可能,对应的服务没开。于是去查看VMnet服务,打开所有服务。
但是还是连接不了。(下面很大一部分没有用,建议找到成功的往上看)
从上图我们可以看出网卡没有激活啊!然后我们激活网卡。
于是又回到/etc/network/interfaces的修改。
下面两个命令,不行。请切换使用看看。如果打开没有内容,写入内容就是
sudo nano /etc/network/interfaces //进入编译如下,底下有命令提示,保存,退出
sudo vi /etc/network/interfaces // 这是修改里面的内容。
sudo /etc/init.d/networking restart //该命令使网络设置生效:
重启服务:
再次尝试:(还是失败,有可能是配置错了)
脾气要好!!!!!!!!!!!!!???????
继续填坑,不能联网的问题:(上面试了所有方法都不行,只能重置所有网络设置)
重置虚拟网络编辑器(管理员执行)
分享主机:(记得使用高级生成一个号)
重启实验结果:
好像已经偏离主题Xshell6连接到虚拟机上回到上面继续
这里就得出一个结论,联网和Xshell6连接不能兼得。
解决可能是22号端口没有被开启
参考:https://blog.csdn.net/u013067756/article/details/76086835
https://blog.csdn.net/liumiaocn/article/details/79427964
操作日志:
zhouyi@ubuntu:~$ su
Password:
root@ubuntu:/home/zhouyi# servicesshd start
servicesshd: command not found
root@ubuntu:/home/zhouyi# service sshd start
Failed to start sshd.service: Unit sshd.service not found.
root@ubuntu:/home/zhouyi# ss -lnt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 127.0.1.1:53 *:*
LISTEN 0 5 127.0.0.1:631 *:*
LISTEN 0 5 ::1:631 :::*
root@ubuntu:/home/zhouyi# service sshd start
Failed to start sshd.service: Unit sshd.service not found.
root@ubuntu:/home/zhouyi# yum install openssh-server
The program 'yum' is currently not installed. You can install it by typing:
apt install yum
root@ubuntu:/home/zhouyi# apt install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
snapd-login-service
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
ssh-askpass rssh molly-guard monkeysphere
The following NEW packages will be installed:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 4 newly installed, 0 to remove and 9 not upgraded.
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://us.archive.ubuntu.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213- 1ubuntu1 [249 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2-4ubuntu2.8 [38.9 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.8 [335 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]
Fetched 633 kB in 10s (60.5 kB/s)
Preconfiguring packages ...
Selecting previously unselected package ncurses-term.
(Reading database ... 216167 files and directories currently installed.)
Preparing to unpack .../ncurses-term_6.0+20160213-1ubuntu1_all.deb ...
Unpacking ncurses-term (6.0+20160213-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a7.2p2-4ubuntu2.8_amd64.deb ...
Unpacking openssh-sftp-server (1:7.2p2-4ubuntu2.8) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a7.2p2-4ubuntu2.8_amd64.deb ...
Unpacking openssh-server (1:7.2p2-4ubuntu2.8) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_5.5-0ubuntu1_all.deb ...
Unpacking ssh-import-id (5.5-0ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Setting up ncurses-term (6.0+20160213-1ubuntu1) ...
Setting up openssh-sftp-server (1:7.2p2-4ubuntu2.8) ...
Setting up openssh-server (1:7.2p2-4ubuntu2.8) ...
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:KOiEAbEYQdAwY2H2Y/33KMVKKSwhbBooX/wraNkP0iQ root@ubuntu (RSA)
Creating SSH2 DSA key; this may take some time ...
1024 SHA256:aUCQROthGwCfGE3V2/LfGwgPccDzA6cYcNW666SQBsA root@ubuntu (DSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:HtFuOxC5/WHeEQcINH2URojlNYxlYNSPPhmxpnU+sDU root@ubuntu (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:M0vEOxv5ZmZTa5zQ+ZKjTnSGa5UOHG6/8I8S5cL6OLg root@ubuntu (ED25519)
Setting up ssh-import-id (5.5-0ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
root@ubuntu:/home/zhouyi# ssh -v
usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-E log_file] [-e escape_char]
[-F configfile] [-I pkcs11] [-i identity_file] [-L address]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-Q query_option] [-R address] [-S ctl_path] [-W host:port]
[-w local_tun[:remote_tun]] [user@]hostname [command]
root@ubuntu:/home/zhouyi# /etc/init.d/ssh status
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)
Active: active (running) since 三 2019-05-15 06:57:18 PDT; 1min 4s ago
Main PID: 16716 (sshd)
CGroup: /system.slice/ssh.service
└─16716 /usr/sbin/sshd -D
5月 15 06:57:18 ubuntu systemd[1]: Starting OpenBSD Secure Shell server...
5月 15 06:57:18 ubuntu sshd[16716]: Server listening on 0.0.0.0 port 22.
5月 15 06:57:18 ubuntu sshd[16716]: Server listening on :: port 22.
5月 15 06:57:18 ubuntu systemd[1]: Started OpenBSD Secure Shell server.
root@ubuntu:/home/zhouyi# service sshd start
root@ubuntu:/home/zhouyi# ss -lnt
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 5 127.0.1.1:53 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 5 127.0.0.1:631 *:*
LISTEN 0 128 :::22 :::*
LISTEN 0 5 ::1:631 :::*
root@ubuntu:/home/zhouyi#
这样确保了22号端口 开启
还是失败,方法都尝试了。我要耐心。。。。。
于是乎我做了从新做了一遍如下指令:查看防火墙-》关闭防火墙自启动-》启用ssh验证连接
zhouyi@ubuntu:~$ sudo ufw status
[sudo] password for zhouyi:
Sorry, try again.
[sudo] password for zhouyi:
Status: inactive
zhouyi@ubuntu:~$ sudo ufw disable
Firewall stopped and disabled on system startup
zhouyi@ubuntu:~$ sudo ufw allow 22
Rules updated
Rules updated (v6)
zhouyi@ubuntu:~$ sudo apt -get install openssh-server
E: Command line option 'g' [from -get] is not understood in combination with the other options.
zhouyi@ubuntu:~$ sudo apt-get install openssh-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
snapd-login-service
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
ncurses-term openssh-sftp-server ssh-import-id
Suggested packages:
ssh-askpass rssh molly-guard monkeysphere
The following NEW packages will be installed:
ncurses-term openssh-server openssh-sftp-server ssh-import-id
0 upgraded, 4 newly installed, 0 to remove and 53 not upgraded.
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://us.archive.ubuntu.com/ubuntu xenial/main amd64 ncurses-term all 6.0+20160213-1ubuntu1 [249 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-sftp-server amd64 1:7.2p2- 4ubuntu2.8 [38.9 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 openssh-server amd64 1:7.2p2-4ubuntu2.8 [335 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 ssh-import-id all 5.5-0ubuntu1 [10.2 kB]
Fetched 633 kB in 11s (54.5 kB/s)
Preconfiguring packages ...
Selecting previously unselected package ncurses-term.
(Reading database ... 213754 files and directories currently installed.)
Preparing to unpack .../ncurses-term_6.0+20160213-1ubuntu1_all.deb ...
Unpacking ncurses-term (6.0+20160213-1ubuntu1) ...
Selecting previously unselected package openssh-sftp-server.
Preparing to unpack .../openssh-sftp-server_1%3a7.2p2-4ubuntu2.8_amd64.deb ...
Unpacking openssh-sftp-server (1:7.2p2-4ubuntu2.8) ...
Selecting previously unselected package openssh-server.
Preparing to unpack .../openssh-server_1%3a7.2p2-4ubuntu2.8_amd64.deb ...
Unpacking openssh-server (1:7.2p2-4ubuntu2.8) ...
Selecting previously unselected package ssh-import-id.
Preparing to unpack .../ssh-import-id_5.5-0ubuntu1_all.deb ...
Unpacking ssh-import-id (5.5-0ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Setting up ncurses-term (6.0+20160213-1ubuntu1) ...
Setting up openssh-sftp-server (1:7.2p2-4ubuntu2.8) ...
Setting up openssh-server (1:7.2p2-4ubuntu2.8) ...
Creating SSH2 RSA key; this may take some time ...
2048 SHA256:CRx9qYEBRyVSoJjxLMjMHMSYAka6OD+X8AsGEXGSYWk root@ubuntu (RSA)
Creating SSH2 DSA key; this may take some time ...
1024 SHA256:kXus80ao3i6JfKp7tNSvDiHHA10Ry8CIJAGzIGqFD7Q root@ubuntu (DSA)
Creating SSH2 ECDSA key; this may take some time ...
256 SHA256:qv20vqEo4DsHPjhSZMUelghELw9xBwPs3xur72XIyh8 root@ubuntu (ECDSA)
Creating SSH2 ED25519 key; this may take some time ...
256 SHA256:GC5eJNvf7b6FDF7xnqW5Vt+8IhF7OU0QTG/kqKMze1M root@ubuntu (ED25519)
Setting up ssh-import-id (5.5-0ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Processing triggers for systemd (229-4ubuntu21.21) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
zhouyi@ubuntu:~$ ifconfig
ens33 Link encap:Ethernet HWaddr 00:50:56:29:69:8a
inet addr:192.168.47.129 Bcast:192.168.47.255 Mask:255.255.255.0
inet6 addr: fe80::d86d:a7f8:2c6f:ab9c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:103020 errors:0 dropped:0 overruns:0 frame:0
TX packets:7819 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:153087042 (153.0 MB) TX bytes:554662 (554.6 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:424 errors:0 dropped:0 overruns:0 frame:0
TX packets:424 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37550 (37.5 KB) TX bytes:37550 (37.5 KB)
最终结果如下:
关于DHCP动态主机配置协议
但是既然这么更新,总是有它的道理。于是去了解。
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)通常被应用在大型的局域网络环境中,主要作用是集中的管理、分配IP地址,使网络环境中的主机动态的获得IP地址、Gateway地址、DNS服务器地址等信息,并能够提升地址的使用率。
2,winScp的使用
上面的配置好之后就可以输入