SSH配置案例

案例配置拓扑
在这里插入图片描述
案例配置要求
1、 互联IP为XY.XY.XY.X/24,Loopback 0的IP为X.X.X.X,其中X为本设备ID,Y为对端设备ID;
2、 三台路由器使用OSPF进行IGP通信;
3、 在R3上使用2009端口配置512bit密钥的SSH;
4、 在R3上创建用户 :R1,密码:cisco;
5、 R3上用于SSH的域名为 www.cisco.com;
案例配置思路
1、 在R1、R2和R3上配置IP:

R1(config)#interface fastEthernet 0/0       
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown                      
R1(config-if)#interface loopback 0             
R1(config-if)#ip address 1.1.1.1 255.255.255.0 
R2(config)#interface fastEthernet 0/0       
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config)#interface fastEthernet 0/1       
R2(config-if)#ip address 23.1.1.2 255.255.255.0
R2(config-if)#no shutdown                      
R2(config-if)#interface loopback 0             
R2(config-if)#ip address 2.2.2.2 255.255.255.0 
R3(config)#interface fastEthernet 0/1       
R3(config-if)#ip address 23.1.1.3 255.255.255.0
R3(config-if)#no shutdown                      
R3(config-if)#interface loopback 0             
R3(config-if)#ip address 3.3.3.3 255.255.255.0 

2、 在三台路由器上配置OSPF,为组播提供IGP连通性;

R1(config)#router ospf 100                  
R1(config-router)#router-id 91.1.1.1               
R1(config-router)#network 1.1.1.0 0.0.0.255 area 0
R1(config-router)#network 12.1.1.0 0.0.0.255 area 0
R2(config)#router ospf 100                  
R2(config-router)#router-id 92.2.2.2               
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R2(config-router)#network 12.1.1.0 0.0.0.255 area 0
R2(config-router)#network 23.1.1.0 0.0.0.255 area 0
R3(config)#router ospf 100                  
R3(config-router)#router-id 93.3.3.3               
R3(config-router)#network 3.3.3.0 0.0.0.255 area 0
R3(config-router)#network 23.1.1.0 0.0.0.255 area 0

3、 在R3上域名:

R3(config)#ip domain-name www.cisco.com

4、 在R3上配置本地用户组和VTY:

R3(config)#username R1 password cisco
R3(config)#line vty 0 4
R3(config-line)#login local

5、 在R3上生成SSH密钥:

R3(config)#crypto key generate rsa 
The name for the keys will be: R3.www.cisco.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
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

6、 在R3上配置SSH:

R3(config)#ip ssh port 2009 rotary 1
R3(config)#line vty 0 4
R3(config-line)#rotary 1
R3(config-line)#transport inp
R3(config-line)#transport input ssh

案例检验结果
1、 配置完成后,在R1上对R3进行SSH登陆:

R1#ssh -l R1 -p 2009 3.3.3.3

Password: 

R3>

2、 配置完成后,在R1上对R3进行Telnet登陆:

R1#telnet 3.3.3.3
Trying 3.3.3.3 ... 
% Connection refused by remote host

案例总结及其它
1、 SSH是一种安全的远程控制协议,它不像telnet那样将数据和密钥一起发送到远端,而是在本地利用密钥对数据进行加密,之后在远端利用密钥解密,增强了数据传输的安全性;
2、 配置SSH的前提之一是本地要设置域名;
3、 配置SSH之前要先设置好crypto密钥;
4、 默认情况下,crypto密钥为512bit,可以手动设置增强安全性;
5、 配置完SSH之后,建议在VTY下关闭其他登陆方式,增强安全性;

发布了231 篇原创文章 · 获赞 222 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qinshangwy/article/details/104834543