cisco SSH配置
1.配置hostname和ip domain-name
switch#configure terminal
switch(config)#hostname R2 //配置ssh的时候路由器的名字不能为router
switch(config)#ip domain-namecisco.com //配置SSH必需
switch(config)#username best password best1
或 username best privilege 15 password 7best1
注:添加一个用户:best,口令:best1
switch(config)#line vty 0 4
switch(config-line)#transport inputssh //只允许用SSH登录(注意:禁止telnet和从
交换引擎session!)
2.配置SSH服务:
switch(config)#crypto key generate rsa
Thename for the keys will be: R2.cisco.com
注:SSH的关键字名就是hostname + . +ip domain-name
Choose the size of the key modulus in the range of 360 to 2048 foryour
General Purpose Keys. Choosing a key modulus greater than 512 maytake
afew minuts
Howmany bits in the modulus [512]: 注:选择加密位数,cisco推荐使用1024
Generating RSA keys ...
[OK]
用命令show ip ssh也能看到:
SSHEnabled - version 1.5
Authentication timeout: 120 secs; Authentication retries:
现在SSH服务已经启动,如果需要停止SSH服务,用以下命令:
R2(config)#crypto key zeroize rsa
3.设置SSH参数
配置好了SSH之后,通过showrun命令我们看到SSH默认的参数:超时限定为120秒,认证重试次数为3次,可以通过下面命令进行修改:
switch(config)#ip ssh {[time-out seconds]} │ [authentication-retriesinterger]}
如果要把超时限定改为180秒,则应该用:
switch(config)# ip ssh time-out 180
如果要把重试次数改成5次,则应该用:
switch(config)# ip ssh authentication-retries
这样,SSH已经在路由器上配置成功了,就能够通过SSH进行安全登录了。
注意:最后如果从别的设备用ssh登录这台设备,就会让我们输入用户名和密码。