博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
通过SSH远程连接Cisco设备
阅读量:6912 次
发布时间:2019-06-27

本文共 2255 字,大约阅读时间需要 7 分钟。

在对网络设备进行远程连接的方法中,最常见的方法是用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#

 

 

转载地址:http://epncl.baihongyu.com/

你可能感兴趣的文章
开源项目之Android StandOut(浮动窗口)
查看>>
分享:树状分类结构,数据库构建(预排序历遍算法)
查看>>
IIS命令
查看>>
学习 easyui 之三:panel 分析
查看>>
BSTR、char*和CString转换
查看>>
盘点影视剧中的那些经典“清流男”
查看>>
CDC,CPaintDC,CClientDC,CWindowDC
查看>>
信号退出【Linux学习笔记】kill及kill -9的用法及如何实现进程的优雅退出
查看>>
搜索引擎是怎么删除重复网页的
查看>>
Objective-C规范注释心得——同时兼容appledoc(docset、html)与doxygen(html、pdf)的文档生成...
查看>>
ARCGIS RUNTIME FOR IOS总结(六)
查看>>
批量scp脚本——从多台机器拷贝文件
查看>>
Oracle 11g安装图文攻略
查看>>
用VBA宏从一个工作薄复制内容到另一个工作薄
查看>>
Android架构分析之使用自定义硬件抽象层(HAL)模块
查看>>
VC6.0启动File-open和Project-add file to project崩溃的解决方法
查看>>
死锁线程探讨Java中的死锁现象
查看>>
Java HashMap的死循环 以及 LRUCache的正确实现
查看>>
地信快享论坛-见习版
查看>>
hdu1244(dp)
查看>>