cisco SSH配置

来源:百度文库 编辑:神马文学网 时间:2024/04/25 00:18:02
1. 配置hostname和ip domain-name
Router#configure terminal
Router(config)#hostname R2 //配置ssh的时候路由器的名字不能为router
R2(config)#ip domain-name cisco.com   //配置SSH必需
R2(config)#username best password best1
注:添加一个用户:best,口令:best1
R2(config)#line vty 0 4
R2(config-line)#transport input ssh      //只允许用SSH登录(注意:禁止telnet和从交换引擎session!)
2. 配置SSH服务:
R2(config)#crypto key generate rsa
The name for the keys will be: R2.cisco.com
注:SSH的关键字名就是hostname + . +ip domain-name
Choose the size of the key modulus in the range of360to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minuts
How many bits in the modulus [512]: 注:选择加密位数,cisco推荐使用1024
Generating RSA keys ...
[OK]
用命令show ip ssh也能看到:
SSH Enabled - version 1.5
Authentication timeout: 120 secs; Authentication retries:
现在SSH服务已经启动,如果需要停止SSH服务,用以下命令:
R2(config)#crypto key zeroize rsa
3.设置SSH参数
配置好了SSH之后,通过show run命令我们看到SSH默认的参数:超时限定为120秒,认证重试次数为3次,可以通过下面命令进行修改:
R2(config)#ip ssh {[time-out seconds]} │ [authentication-retries interger]}
如果要把超时限定改为180秒,则应该用:
R2(config)# ip ssh time-out 180
如果要把重试次数改成5次,则应该用:
R2(config)# ip ssh authentication-retries
这样,SSH已经在路由器上配置成功了,就能够通过SSH进行安全登录了。
注意:最后如果从别的设备用ssh登录这台路由器会出现以下内容:
R1#ssh -l best 192.168.0.2
Password:
R2>en
% Error in authentication.
为什会出现以上内容?
因为在R2上没有配置enable password/secret xxxx
R2配置上enable secret 5 $1$fJxo$suWiTzmfdj/vkvXfRHBcw/
那么在R1上:
R1#ssh -l best 192.168.0.2
Password: