拓撲圖

配置教程
一.添加pc0的ip為192.168.1.2

交換機配置
Switch>ena
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#ip domain-name cnblogs.com //綁定域名為cnblogs.com
Switch(config)#ho s1 //命名交換機為s1
s1(config)#cr key generate rsa //生成RSA 秘鑰
The name for the keys will be: s1.cnblogs.com
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: 1024 //最大2048位
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
s1(config)#enable password s1 //設置特權模式密碼為s1
s1(config)#username s1 secret s1 //設置交換機用戶名為s1 密碼為s1
s1(config)#line vty 0 15 創建vty線路
s1(config-line)#transport input ssh
s1(config-line)#login local
s1(config-line)#int vlan 1 //因為所有通道在端口未被配置ip的情況下默認使用VLAN1
s1(config-if)#ip ad 192.168.1.1 255.255.255.0
s1(config-if)#no sh
s1(config-if)#
%LINK-5-CHANGED: Interface Vlan1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
s1(config-if)#
配置完成
使用pc0 ping 交換機剛剛配置的ip:192.168.1.1

使用pc0 ssh鏈接交換機
使用命令:
ssh -l s1(剛剛的用戶名)192.168.1.1(配置的ip)

注意:輸入密碼時通常不會顯示明文密碼,是需要輸入剛剛設置的密碼:s1

成功用ssh進入交換機
為了交換機的安全通常會將特權模式設置一個密碼,當設備退出特權模式或使用ssh鏈接使用特權模式時會要求輸入特權模式的密碼

這里也一樣,不會顯示明文密碼
輸入剛剛設置的密碼后進入特權模式

配置完成
注:兩層交換機和三層交換機配置一樣
