本文主要講解:使用虛機(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了!