R1:(充当PC,配置接口ip)
[R1]int g0/0/0 //接入接口
[R1-GigabitEthernet0/0/0]ip add 192.168.20.1 24 //配置ip,子网掩码24位(255.255.255.0)
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.10.1 24
[R1-GigabitEthernet0/0/1]q
[R1]ssh client first-time enable //登陆端配置(使能ssh客户端首次认证不检查公钥)
R2:配置telnet
<Huawei>sys
[Huawei]undo info-center enable //关闭信息中心
[Huawei]sys R2
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.20.2 24 //配置ip,子网掩码24位(255.255.255.0)
[R2-GigabitEthernet0/0/1]q
[R2]user-interface vty 0 4 //进入vty终端,允许5个用户
[R2-ui-vty0-4]authentication-mode password //认证模式为:密码
Please configure the login password (maximum length 16):1234567 //设置telnet密码 1234567
[R2-ui-vty0-4]user privilege level 15 //配置用户telnet连接权限等级为15
[R2-ui-vty0-4]q
[R2]q
<R2>
R3:配置telnet aaa
<Huawei>sys
[Huawei]sys R3
[R3]undo info-center enable //关闭信息中心
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.10.2 24 //配置ip,子网掩码24位(255.255.255.0)
[R3-GigabitEthernet0/0/1]q
[R3]user-interface vty 0 4
[R3-ui-vty0-4]authentication-mode aaa //认证模式为:aaa认证
[R3-ui-vty0-4]q
[R3]aaa //进入aaa功能配置项
[R3-aaa]local-user admin password cipher 123000 //创建用户,用户名admin密码123000
[R3-aaa]local-user admin privilege level 15 //admin用户等级为15(最高级)
[R3-aaa]local-user admin service-type telnet //admin用户类型为telnet
[R3-aaa]q
[R3]
R4: ssh配置
<Huawei>sys
[Huawei]sys R4
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 192.168.30.2 24
[R4-GigabitEthernet0/0/0]q
[R4]stelnet server enable //启用ssh功能
Info: Succeeded in starting the STELNET server.
[R4]user-interface vty 0 4
[R4-ui-vty0-4]authentication-mode aaa
[R4-ui-vty0-4]protocol inbound ssh //允许ssh流量通过
[R4-ui-vty0-4]q
[R4]aaa
[R4-aaa]local-user aduuu password cipher 123000
Info: Add a new user.
[R4-aaa]local-user aduuu privilege level 15
[R4-aaa]local-user aduuu service-type ssh //用户aduuu类型为ssh
[R4-aaa]q
[R4]rsa local-key-pair create 生成服务器密钥对(非必要配置项)
The key name will be: Host
% RSA keys defined for Host already exist.
Confirm to replace them? (y/n)[n]:y // 确认覆盖原有秘钥 y
The range of public key size is (512 ~ 2048).
NOTES: If the key modulus is greater than 512,
It will take a few minutes.
Input the bits in the modulus[default = 512]:1024 //默认512,可改成1024
Generating keys...
.++++++
.............................++++++
................++++++++
........++++++++
[R4]
备注:
新版本增加的功能。
ssh server-source all-interface 指定SSH服务器的源接口为设备上所有配置ip的接口
或
ssh server-source -i interface xxxx,指定SSH服务器的源接口为某一个接口。
如果同时配置,则会优先选择ssh server-source -i命令指定的接口作为ssh服务器的源接口,如果指定的源接口无法登录成功,则会从其他有效接口中选择接口登录。