| Gzu521.com我的学习网 |
|
ssh的英文全称是secure shell,是由芬兰的一家公司开发的。ssh由客户端和服务端的软件组成,有1.x和2.x两个不兼容的版本。ssh的功能强大,既可以代替telnet,又可以为Ftp、pop3和ppp提供一个安全的“通道”。使用ssh,可以把传输的所有数据进行加密。即使有人截获到数据也无法得到有用的信息。同时,数据经过压缩,大大地加快传输的速度。 本文将详细介绍在CISCO路由器上用ssh实现安全登录的配置方法。该方法简单易行,安全性高,适于在网络维护工作中推广使用。 2、在cisco路由器上配置ssh服务 在cisco路由器产品系列中只有7200系列、7500系列和12000系列(gsr)等高端产品的ios支持ssh。一般支持ssh的ios版本文件名中都带有k3或者k4字样,k3 代表56bit ssh 加密,k4代表168bit ssh加密。如我省省网gsr 12016和12008上用的ios 就是一个支持56bit ssh 加密的版本。目前cisco的产品只支持ssh-1,还不支持ssh-2。下面以gsr 12008为例详细介绍ssh-1的配置方法(斜体字为配置输入的命令): ① 配置hostname和ip domain-name: router#configure terminal router(config)#hostname test-gsr12008 test-gsr12008(config)#ip domain-name jx.cn.net ② 配置登录用户名和密码(以本地认证为例): test-gsr12008(config)#username test password 0 test 注:添加一个用户:test,口令:test test-gsr12008(config)#line vty 0 4 test-gsr12008(config-line)#login local 在这两部分做完以后,用show run命令就能够看到: hostname test-gsr12008 ! boot system flash gsr-k3p-mz.120-14.s.bin enable secret 5 $1$dmyw$gdsiokcr7p8ytwcrwtnjg. enable password 7 094f47c31a0a ! username test password 7 0835495d1d clock timezone prc 16 redundancy main-cpu auto-sync startup-config ! ! ! ! ip subnet-zero no ip finger ip domain-name jx.cn.net ip name-server 202.101.224.68 ip name-server 202.101.226.68 ! ③ 配置ssh服务: test-gsr12008(config)#crypto key generate rsa the name for the keys will be: test-gsr12008.jx.cn.net 注:ssh的关键字名就是hostname + . +ip domain-name 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]: 注:选择加密位数,用默认就行了 generating rsa keys ... [ok] test-gsr12008(config)#end test-gsr12008#write building configuration... 这时候用show run命令可以看到: ip subnet-zero no ip finger ip domain-name jx.cn.net ip name-server 202.101.224.68 ip name-server 202.101.226.68 ip ssh time-out 120 ip ssh authentication-retries 3 ! 用命令show ip ssh也能看到: ssh enabled - version 1.5 authentication timeout: 120 secs; authentication retries: 3 现在ssh服务已经启动,如果需要停止ssh服务,用以下命令: test-gsr12008(config)#crypto key zeroize rsa ④设置ssh参数 配置好了ssh之后,通过show run命令我们看到ssh默认的参数:超时限定为120秒,认证重试次数为3次,可以通过下面命令进行修改: test-gsr12008(config)#ip ssh {[time-out seconds]} | [authentication-retries interger]} 如果要把超时限定改为180秒,则应该用: test-gsr12008(config)# ip ssh time-out 180 如果要把重试次数改成5次,则应该用: test-gsr12008(config)# ip ssh authentication-retries 5 这样,ssh已经在路由器上配置成功了,就能够通过ssh进行安全登录了 |
责任编辑:gzu521