某公司有一台核心设备R1,为了方便进行管理,配置SSH远程登录,使用路由器R2模拟客户端,配置SSH协议登录R1。

实验拓扑如下:
在这里插入图片描述
R1配置:
Router>en
Router#conf
Router(config)#hostname R1
R1(config)#int f0/0
R1(config-if)#ip add
R1(config-if)#hostname R1
R1(config-if)#ip add
R1(config-if)#ip add
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#no shutdown
R1(config-if)#ex
R1(config-if)#exit
R1(config)#username ccna pa
R1(config)#username ccna password ccna //设置登录使用的用户名密码和信息
R1(config)#ip domain-na
R1(config)#ip domain-name 123.com //设置ip域名
R1(config)#
R1(config)#cry
R1(config)#crypto ke
R1(config)#crypto key ge
R1(config)#crypto key generate rsa //生成RSA密钥对
The name for the keys will be: R1.123.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 //设置密钥对长度为1024
% Generating 1024 bit RSA keys, keys will be non-exportable…[OK]

R1(config)#
*3? 1 0:5:49.938: %SSH-5-ENABLED: SSH 1.99 has been enabled

配置vty
R1(config)#lin
R1(config)#line v
R1(config)#line vty 0 4
R1(config-line)#tr
R1(config-line)#transport in
R1(config-line)#transport input ssh //打开SSH登录服务
R1(config-line)#log
R1(config-line)#login lo
R1(config-line)#login local
R1(config-line)#

ssh的其它配置:
R1(config)#ip ssh time-out 30 //设置ssh超时时间为30s
R1(config)#ip ssh au
R1(config)#ip ssh authentication-retries 5 //设置ssh认证失败的次数为5次
R1(config)#ip ssh ver
R1(config)#ip ssh version 2 //设置ssh的版本

R2配置:
Router#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ho
Router(config)#hostname R2
R2(config)#
R2(config)#
R2(config)#int f0/0
R2(config-if)#ip add
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#no shutdown

验证:客户端R2登录R1
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐