类别:CISCO / 日期:2019-10-09 / 浏览:1994 / 评论:0

    思科设备中,当使用telnet进行远程设备维护时,由于密码和通讯都是明文的,易受sniffer侦听,所以应采用ssh替代telnet。SSH(Secure Shell)服务使用tcp 22端口,客户端软件发起连接请求后从服务器接受公钥,协商加密方法,成功后所有的通讯都是加密的。Cisco设备目前支持SSH v1和v2版本,目前几乎所有cisco路由交换产品均支持SSH,但要求IOS版本支持安全特性。cisco实现SSH的目的在于提供较安全的设备管理连接,不适用于主机到主机的通讯加密。目前SSH配置有两种方式:不启用AAA的SSH配置和启用AAA的SSH配置。

1、不启用AAA的SSH配置:
router(config)#ip domain-name itfisher.com    //设置域名
router(config)#crypto key generate rsa    //生成密钥
The name for the keys will be: router.itfisher.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]
router(config)#username itfisher secret 123456     //指定SSH登陆的用户名itfisher和密码123456
router(config)#ip ssh time-out 30    //设定SSH超时值
router(config)#ip ssh version 2     //指定SSH版本为V2,或用“no ip ssh version”启用v1和v2版本
router(config)#ip access-list standard forssh      //定义SSH登陆源地址
router(config-std-nacl)#permit any    //SSH登陆源地址不受限制
router(config-std-nacl)#exit
router(config)#line vty 0 15       //进入vty线路接口
router(config-line)#exec-timeout 30     //设定vty线路登陆超时值
router(config-line)#login local     //使用本地数据库
router(config-line)#transport input ssh     // vty线路登陆方式只允许为SSH
router(config-line)#access-class forssh in         //应用访问列表
router(config-line)#exit
router(config)#enable secret 654321     //登陆后进入EXEC特权模式所用的密码为654321

2、启用AAA的SSH配置:
router(config)#ip domain-name itfisher.com    //设置域名
router(config)#aaa new-model     //启用AAA服务
router(config)#crypto key generate rsa    //生成密钥
The name for the keys will be: router.itfisher.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]
router(config)#username itfisher secret 123456     //指定SSH登陆的用户名itfisher和密码123456
router(config)#ip ssh time-out 30     //设定SSH超时值
router(config)#ip ssh version 2     //指定SSH版本为V2,或用“no ip ssh version”启用v1和v2版本
router(config)#aaa authentication login ssh local line none //设定SSH登陆信息存储地方
router(config)#ip access-list standard forssh     //定义SSH登陆源地址
router(config-std-nacl)#permit any     //SSH登陆源地址不受限制
router(config-std-nacl)#exit
router(config)#line vty 0 15     //进入vty线路接口
router(config-line)#exec-timeout 30     //设定vty线路登陆超时值
router(config-line)#login authentication ssh     //指定验证登陆用户信息存储的地方
router(config-line)#transport input ssh     // vty线路登陆方式只允许为SSH
router(config-line)#access-class forssh in     //应用访问列表
router(config-line)#exit
router(config)#enable secret 654321     //登陆后进入EXEC特权模式所用的密码为654321

3、关闭SSH服务
router(config)#crypto key zeroize rsa 
% All RSA keys will be removed.
% All router certs issued using these keys will also be removed.
Do you really want to remove these keys? [yes/no]: y
关闭后再想开启的话只需使用:
router(config)#crypto key generate rsa
How many bits in the modulus [512]: 1024  
即可,其它的不必重设。

打赏

感谢您的赞助~

打开支付宝扫一扫,即可进行扫码打赏哦~

版权声明 : 本文未使用任何知识共享协议授权,您可以任何形式自由转载或使用。

 可能感兴趣的文章