如何配置思科交换机只允许SSH登录?
首先如果思科交换机IOS版本过低的是不支持SSH的,检测方法是执行crypto key generate rsa时提示没有这个命令那就是IOS版本不支持SSH了。
以下以思科3750交换机为例配置交换机只允许SSH登录,配置方法如下:
进入全局配置模式
conf t
1.启用ssh 首先需要创建用户
username cisco password ciscocisco
注意:如果通过查看交换机配置(show run)已经产生过密钥了2和3步骤可以跳过
2.配置一个域名
ip domain-name cisco.cn
3.生成密钥组
crypto key generate rsa 密钥长度设置为:2048位
4.指定ssh版本
ip ssh version 2 //配置SSH版本2
ip ssh time-out 120//配置SSH登入超时时间
ip sshauthentication-retries 5 //登录重试次数
login block-for 600 attempts 5 within 60 //60秒内错误登录5次,锁定600秒
5.配置只允许SSH
配置0到4号线路只运行SSH
line vty 0 15 //进入line接口
login local //采用本地验证
exec-timeout 5 30 //配置会话超时,5分30秒后无操作则断开连接
transport input ssh //指定只能用ssh登陆
exit
6.关闭http访问
no ip http server
console口配置
config t
line con 0
password ciscocisco
login
exec-timeout 5 30
end
wr //保存配置
注意:上面设置了只允许ssh登录那么telnet自然就关闭了。对于不支持SSH的交换机想要关闭telnet可以使用如下方法
conf t
line vty 0 15
no password
transport input none
end
wr