通過SSH遠端連線Cisco裝置
在對網路裝置進行遠端連線的方法中,最常見的方法是用telnet,而所有通過telnet會話傳遞的資料都是以明文的方式進行傳遞的,當這些資料被擷取之後,就會被輕易的讀出原文,所以為了安全性,把資料進行加密後再傳輸,那麼這種方式就是SSH
SSH有兩個版本 ver1和ver2 在預設情況下當我們開啟ssh時,ssh的版本為ver1.
使用SSH的幾點注意事項:
1.裝置必須擁有支援IPsec加密的IOS
2.必須為裝置配置主機名和域名
3.配置 RSA Key (配置之後SSH就開啟了)
SSH分為server和client兩種,server就是提供SSH登陸的裝置,client就是發起ssh會話的裝置,SSH會話沒有資料傳遞時,預設超時是120s,SSH最大連線數量就是VTY所允許的數量。
實驗:通過ssh對裝置進行遠端連線
進行基本配置,讓PC和R1可以通訊
PC的配置如下
路由器配置
Router(config)#hostname r1
r1(config)#int lo 0
r1(config-if)#ip add 1.1.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#exit
r1(config)#int f0/0
r1(config-if)#ip add 172.16.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#exit
PC和路由器可以成功通訊
下面開始配置SSH
1.r1(config)#ip domain-name contoso.com 為裝置配置域名
2.r1(config)#crypto key generate rsa 配置RSA
The name for the keys will be: r1.contoso.com
Choose the size of the key modulus in the range of 360 to 2048 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]: 1024 修改位元數為1024
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
r1(config)#
3.建立裝置的使用者名稱和密碼,客戶端帳號通過此賬戶登陸
4.在VTY下開啟認證,並指定SSH可以登陸
r1(config)#line vty 0 4
r1(config-line)#login local 用裝置本地的賬戶密碼進行登陸
r1(config-line)#tran
r1(config-line)#transport ?
input Define which protocols to use when connecting to the terminal server
output Define which protocols to use for outgoing connections
r1(config-line)#transport in
r1(config-line)#transport input ?
all All protocols
none No protocols
ssh TCP/IP SSH protocol
telnet TCP/IP Telnet protocol
r1(config-line)#transport input ssh ?
<cr>
r1(config-line)#transport input ssh 配置登陸方式為SSH
r1(config-line)#
下面我們開始測試客戶端用SSH登陸
我們看到,客戶端成功和R1發起SSH會話
此時我們即實現 通過SSH 來遠端登陸Cisco裝置
檢視SSH版本
r1#show ip ssh
SSH Enabled - version 1.99 版本為1 預設情況下
Authentication timeout: 120 secs; Authentication retries: 3 認證超時120秒 認證重試3次
r1#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#ip shh
r1(config)#ip ssh ver
r1(config)#ip ssh version 2 修改SSH版本為 version2
r1(config)#exit
r1#
%SYS-5-CONFIG_I: Configured from console by console
r1#show ip ssh
SSH Enabled - version 2.0 此時SSH版本為2.0
Authentication timeout: 120 secs; Authentication retries: 3
r1#
轉載於:https://blog.51cto.com/liushuo890/1103443