當我們使用telnet登入到裝置時,使用者名和密碼是采用明文的方式傳輸的,為了保證資料的安全,建議采用SSH的方式登入裝置。以下就是Cisco路由器SSH的配置:
1. 配置hostname和domain-name
R1(config)#hostname R1
R1(config)#ip domain-name frame.com
2. 産生密鑰,這裡産生的是1024位的密鑰,密鑰長度範圍為360-2048
R1(config)#crypto key generate rsa general-keys modulus 1024
The name for the keys will be: R1.frame.com
% The key modulus size is 1024 bits
% Generating 1024 bit RSA keys, keys will be non-exportable…[OK]
R1(config)#
3. 配置SSH的資訊
配置所使用的SSH版本:
R1(config)#ip ssh version 2
配置SSH會話的逾時時間:
R1(config)#ip ssh time-out 120
配置SSH認證的最大次數:
R1(config)#ip ssh authentication-retries 3
啟用SSH和telnet認證:
R1(config)#line vty 0 4
R1(config-line)#transport input ssh telnet
R1(config-line)#login local //使用本地認證,登入時必須輸入使用者名和密碼才可以,如果是no login,則不需要密碼
4. 配置本地認證使用者
R1(config)#username frame password cisco
5. telnet和ssh登入測試
Telnet登入:
R2#telnet 1.1.1.1
Trying 1.1.1.1 … Open
Username: frame
Password:
R1>
SSH登入:
R2#ssh -l frame 1.1.1.1
通過使用-l指定登入的使用者名。
伺服器端檢視SSH會話:show ssh
R1#sh ssh
Connection Version Mode Encryption Hmac State Username
0 1.99 IN aes128-cbc hmac-sha1 Session started frame
0 1.99 OUT aes128-cbc hmac-sha1 Session started frame
%No SSHv1 server connections running.
本文轉自 sunrisenan 51CTO部落格,原文連結:http://blog.51cto.com/sunrisenan/1871858