SSH(Secure Shell)是用于安全远程登录的网络协议,通过加密通信保障数据传输安全。核心配置要素包括:
配置项 | 思科(Cisco) | 华为(Huawei) | 华三(H3C) | 锐捷(Ruijie) |
---|---|---|---|---|
密钥生成命令 | crypto key generate rsa | rsa local-key-pair create | public-key local create rsa | crypto key generate rsa |
SSH版本控制 | ip ssh version 2 | ssh server compatible-ssh1x disable | ssh server compatibility legacy disable | ssh version 2 |
VTY认证模式 | login local | authentication-mode aaa | authentication-mode scheme | login authentication local |
用户权限设置 | privilege level 15 | user privilege level 15 | authorization-attribute user-role network-admin | privilege level 15 |
默认SSH端口 | 22 | 22 | 22 | 22 |
ACL应用方式 | access-class <ACL> in | acl <ACL> inbound | acl <ACL> inbound | access-class <ACL> in |
! 配置域名(必须)
conf t
hostname Router
ip domain-name cisco.com
! 生成RSA密钥
crypto key generate rsa modulus 2048
! 配置SSH参数
ip ssh version 2
ip ssh time-out 90
ip ssh authentication-retries 3
! 创建本地用户
username admin privilege 15 secret Admin@123
! 配置VTY线路
line vty 0 4
transport input ssh
login local
access-class 10 in
exit
! 创建ACL(可选)
ip access-list standard 10
permit 192.168.1.0 0.0.0.255
sys
sysname Switch
# 生成RSA密钥
rsa local-key-pair create
# 配置SSH参数
stelnet server enable
ssh user admin
ssh user admin authentication-type password
ssh user admin service-type stelnet
ssh server compatible-ssh1x disable
# 创建本地用户
aaa
local-user admin password irreversible-cipher Admin@123
local-user admin privilege level 15
local-user admin service-type ssh
quit
# 配置VTY线路
user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
acl 2000 inbound
quit
# 创建ACL(可选)
acl 2000
rule permit source 192.168.1.0 0.0.0.255
sys
sysname Switch
# 生成RSA密钥
public-key local create rsa
# 配置SSH参数
ssh server enable
ssh server authentication-retries 3
ssh server timeout 90
# 创建本地用户
local-user admin class manage
password hash Admin@123
service-type ssh
authorization-attribute user-role network-admin
# 配置VTY线路
line vty 0 63
authentication-mode scheme
protocol inbound ssh
acl basic 2000 inbound
quit
# 创建ACL(可选)
acl basic 2000
rule permit source 192.168.1.0 0.0.0.255
enable
configure terminal
hostname Switch
# 生成RSA密钥
crypto key generate rsa modulus 2048
# 配置SSH参数
ip ssh version 2
ip ssh timeout 90
ip ssh authentication-retries 3
# 创建本地用户
username admin privilege 15 password Admin@123
# 配置VTY线路
line vty 0 4
login authentication local
transport input ssh
access-class 10 in
exit
# 创建ACL(可选)
ip access-list standard 10
permit 192.168.1.0 0.0.0.255
注意:所有密码建议使用复杂密码并定期更换,SSH版本建议强制使用v2,ACL应根据实际网络环境配置访问控制策略。