最近客户要求修改大量路由器、防火墙的SSH访问,于是整理了一下,就这样配置了
路由器与交换机 有些版本IOS不支持SSH
Hostname XXXX
//ssh要求必须配置设备名称
enable secret cisco
//eanble密码
ip domain name cisco.com
//ssh要求配置域名,可任意名
login block-for 1800 attempts 3 within 60
//ssh在60秒内3次登录错误,则在1800秒内禁止登录
username cisco privilege 15 password 0 cisco //配置ssh登录用户,并指定权限(不加权限也可以,默认也是如此)
access-list 23 permit 192.168.1.222
//允许ssh登录的主机IP(使用网段也可以)
crypto key generate rsa
//生产ssh访问密钥
1024
//可选1024,默认512
ip ssh version
//可更改ssh版本,默认为版本1
line vty 0 4 //各时间都可根据需要更改
access-class 23 in
//应用访问控制列表
exec-timeout 30 0
//远程登录30分钟后退出
logout-warning 40
//无操作40秒提示
absolute-timeout 1
//无操作1分钟退出
login local
//本地认证
transport input ssh
//只允许ssh方式登录
防火墙
crypto key generate rsa modulus 1024
//生产ssh访问密钥
wr mem //保存产生的密钥,有人说这个命令不作用,得用ca save all,但我这样用,重启了,也是好用的
ssh 192.168.1.222 255.255.255.255 outside
//允许访问的主机IP,outside也可以改为inside
ssh timeout 30
//设置访问超时为30分钟
enable password cisco
//enable密码
passwd cisco
//ssh访问密码
//ssh访问默认用户为pix
如果不希望使用pix作为ssh login的用户名,则需要下列配置
aaa authentication ssh console LOCAL (必须使用大写)
aaa authentication telnet console LOCAL 可选
aaa authentication enable console LOCAL 可选。此三条命令互不影响
username cisco password cisco encrypted privilege 15
这样就可以使用用户名cisco来替代默认的pix.
username cisco password cisco encrypted privilege 15
这样就可以使用用户名cisco来替代默认的pix.
转载于:https://blog.51cto.com/zxf1979/479753