本文主要讲解:使用虚机(Vitual Box)安装的vyOS,如何使用Xshell来通过ssh方式连接。
首先咱们安装vyOS
1.安装vyOS
先用Vitual Box
安装vyOS
镜像。
接下来的操作其实官网教程讲的很清楚了,基本就是一路默认往下点就可以。
主要就是执行这条语句install image
vyos@vyos:~$ install image
Welcome to the VyOS install program. This script
will walk you through the process of installing the
VyOS image to a local hard drive.
Would you like to continue? (Yes/No) [Yes]: Yes
Probing drives: OK
Looking for pre-existing RAID groups...none found.
The VyOS image will require a minimum 2000MB root.
Would you like me to try to partition a drive automatically
or would you rather partition it manually with parted? If
you have already setup your partitions, you may skip this step
Partition (Auto/Parted/Skip) [Auto]:
I found the following drives on your system:
sda 4294MB
Install the image on? [sda]:
This will destroy all data on /dev/sda.
Continue? (Yes/No) [No]: Yes
How big of a root partition should I create? (2000MB - 4294MB) [4294]MB:
Creating filesystem on /dev/sda1: OK
Done!
Mounting /dev/sda1...
What would you like to name this image? [1.2.0-rolling+201809210337]:
OK. This image will be named: 1.2.0-rolling+201809210337
Copying squashfs image...
Copying kernel and initrd images...
Done!
I found the following configuration files:
/opt/vyatta/etc/config.boot.default
Which one should I copy to sda? [/opt/vyatta/etc/config.boot.default]:
Copying /opt/vyatta/etc/config.boot.default to sda.
Enter password for administrator account
Enter password for user 'vyos':
Retype password for user 'vyos':
I need to install the GRUB boot loader.
I found the following drives on your system:
sda 4294MB
Which drive should GRUB modify the boot partition on? [sda]:
Setting up grub: OK
Done!
vyos@vyos:~$
最后重启系统:
vyos@vyos:~$ reboot
Proceed with reboot? (Yes/No) [No] Yes
2.配置vyOS可通过SSH连接
2.1 进入配置模式
vyos@vyos$ configure
vyos@vyos#
2.2 配置网络接口
vyos@vyos# set interfaces ethernet eth0 address dhcp
vyos@vyos# set interfaces ethernet eth0 description 'OUTSIDE'
2.3 启用ssh
vyos@vyos# set service ssh port '22'
2.4 保存改动
vyos@vyos# commit
vyos@vyos# save
3. 配置Xshell连接
3.1 获取连接ip
接着2.4
的操作:
vyos@vyos# exit
vyos@vyos$ sudo ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:40:ac:ef
inet addr:你需要复制的地址 Bcast:XXX.XXX.XXX.XXX Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe40:acef/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2425 errors:0 dropped:0 overruns:0 frame:0
TX packets:185 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:237660 (232.0 KiB) TX bytes:19908 (19.4 KiB)
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:30910 errors:0 dropped:0 overruns:0 frame:0
TX packets:30910 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1865376 (1.7 MiB) TX bytes:1865376 (1.7 MiB)
你如果直接把上面的ip地址复制进入Xshell连接配置的主机(H)
栏,大概率是连不上虚机中的vyOS的,
在进行接下来的操作之前,我们还需要修改虚机的桥接模式
3.2 修改虚机桥接模式
选择vyOS虚机,右键 > 设置 > 网络 > 网卡1 > 连接方式 > 选择桥接网卡
。
执行完上面操作后,咱们再次获取连接ip,操作同3.1
。
3.3 再次获取连接ip
将获取到的ip填入到Xshell连接配置的主机(H)
栏。账号密码都是安装vyOS
时候设置的。即vyos
。
这样一来,就OK了!