欢迎来访~

思科交换机SSH登录配置

思科交换机SSH配置非常基础,简单,官网也比较容易查询,但还是记录一下吧。

SSH的优势

在现在这个信息时代,网络安全变得越来越重要,当然路由器交换机作为数据传输的环节,安全性更为重要。

现在的网络设备一般都是支持SSH和Telnet远程登录的,新设备一般默认建议SSH登录。

Telnet是明文传送,SSH是密文传送,这是最主要的区别。

SSH替代Telnet是趋势也是现实。在使用SSH的时候,一个数字证书将认证客户端(你的工作站)和服务器(你的网络设备)之间的连接,并加密受保护的口令。SSH1使用RSA加密密钥,SSH2使用数字签名算法(DSA)密钥保护连接和认证。加密算法包括Blowfish,数据加密标准(DES),以及三重DES(3DES)。SSH保护并且有助于防止欺骗,“中间人”攻击,以及数据包监听。
通过使用SSH把所有传输的数据进行加密,这样“中间人”这种攻击方式就不可能实现了,而且也能够防止DNS和IP欺骗。还有一个额外的好处就是传输的数据是经过压缩的,所以可以加快传输的速度。SSH有很多功能,它既可以代替telnet,又可以为ftp、pop、甚至ppp提供一个安全的“通道”。

SSH配置

1.配置设备名称,domain名称,生成RSA 密钥对

Switch#configure terminal
Switch(config)#hostname test
test(config)#ip domain-name hello2099.com
test(config)#crypto key generate rsa
The name for the keys will be: test.hello2099.com
Choose the size of the key modulus in the range of 360 to 4096 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.

How many bits in the modulus [512]:
% Generating 512 bit RSA keys, keys will be non-exportable…
[OK] (elapsed time was 0 seconds)

要删除 RSA 密钥对,请使用 crypto key zeroize rsa 全局配置模式命令。删除 RSA 密钥对之后,SSH 服务将自动禁用。

2.配置SSH版本,超时时间,重认证次数

test(config)#ip ssh version 2
test(config)#ip ssh time-out 90
test(config)#ip ssh authentication-retries 2

以上参数可根据实际情况自行选择。对于比较新的iso,可以直接敲入 ip ssh time-out 90 authentication-retries 2

3.配置用户身份验证和vty线路。

SSH登陆需要用户名和密码,所以必须要配置用户。我这里使用的是本地认证,实际环境中AAA认证同理。

test(config)#username cisco secret cisco
test(config)#enable secret cisco
test(config)#line vty 0 4
test(config-line)#login local
test(config-line)#transport input ssh

如需关闭Telnet,只开启SSH,敲入transport input ssh

如需同时支持SSH和Telnet,敲入transport input all

test(config-line)#transport input ?
all All protocols
none No protocols
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol

一般情况下line vty 0 4配置完成后,建议将vty 5 15关闭,因为如果vty 0 4启用了SSH登录而vty 5 15没有,远程Telnet会绕过vty 0 4而使用vty 5 15。如下面的情况:

 

因此建议将vty 5 15关闭。
test(config-line)#line vty 5 15
test(config-line)#transport input none

再次登录,就完全关闭了Telnet,只能使用SSH。

4.检查SSH登录

test#show ssh
Connection Version Mode Encryption Hmac State Username
0 2.0 IN aes256-ctr hmac-sha1 Session started cisco
0 2.0 OUT aes256-ctr hmac-sha1 Session started cisco
%No SSHv1 server connections running.

test#show ip ssh
SSH Enabled – version 2.0
Authentication methods:publickey,keyboard-interactive,password
Encryption Algorithms:aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
MAC Algorithms:hmac-sha1,hmac-sha1-96
Authentication timeout: 90 secs; Authentication retries: 2
Minimum expected Diffie Hellman key size : 1024 bits
IOS Keys in SECSH format(ssh-rsa, base64 encoded):
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNYkHIP4uyK+jxLV6n3AlBtUaa6O53K9u2qrtQQu+v
jdmW9vhhsiFaDUDf4fROkczE+6FskpgeqEdP6MtqxCO8CNAPIxqDIYR/bBGtWBhhEsPmrgpQBGWCKSyJ
aRBLdeCRJXmYLEDZXCcEtmJQf6Iu7zCV9ZMxO0A1/2B4Si9Dgw==

配置范例

Switch(config)# hostname test
test(config)# ip domain-name hello2099.com
test(config)# crypto key generate rsa
test(config)# ip ssh version 2
test(config)# ip ssh time-out 90
test(config)# ip ssh authentication-retries 2
test(config)# username cisco secret cisco
test(config)# enable secret cisco
test(config)# line vty 0 4
test(config-line)# login local
test(config-line)# transport input ssh
test(config)# line vty 5 15
test(config-line)# transport input none

 

赞(7)
可附来源转载:一只北极熊 » 思科交换机SSH登录配置

富强、民主、文明、和谐、自由、平等、公正、法治、爱国、敬业、诚信、友善