通过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#

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值