交换机与路由器技术-04-远程管理交换机

目录

一、通过远程连接管理设备

1.1 telnet介绍

1.2 SSH介绍

1.3 Telnet远程管理思路

1.配置IP地址

2.配置设备连接终端(vty终端)

3.配置特权模式密码

1.4 补充VTY介绍

1.5 思科设备telnet连接认证方式

1.6 总结:Telnet配置流程

1.7 SSH配置思路

1.给交换机虚接口VLAN 1设置IP

2.配置SSH

3.创建本地用户名和密码

4.配置特权模式密码

5.进入vty虚终端,应用生效

6.在虚拟机中查看效果

1.8 总结:SSH配置流程


一、通过远程连接管理设备

使用的协议:telnet、ssh

1.1 telnet介绍

telnet是应用层协议,基于传输层TCP的23号端口 采用明文密码方式,不是太安全。一般用于内网管理。

1.2 SSH介绍

SSH是Secure Shell缩写,建立在应用层的安全协议,基于传输层TCP的22号端口,采用密文密码方式,相对来讲比较安全,经常用于跨越互联网管理,也常用于远程管理Linux服务器

1.3 Telnet远程管理思路

1.配置IP地址

既然是通过网络的方式管理设备,设备必须配置IP地址,由于交换机上的接口都是交换接口,无法在接口上配置IP,交换接口不允许配置IP地址,所以直接为交换机的虚接口VLAN 1 配置IP地址,默认情况下交换机的默认虚接口就是VLAN 1。所有交换接口都默认属于VLAN 1

Switch#

Switch#conf

Switch#

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#int vlan 1                               //进入虚接口vlan 1

Switch(config-if)#ip address 192.168.10.2 255.255.255.0    //配置IP地址和子网掩码

Switch(config-if)#no shutdown                      //开启接口,默认是关闭的

Switch(config-if)#

%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

2.配置设备连接终端(vty终端)

设置对应的密码或用户名

方式一:进入虚拟终端后可以直接设置密码使用password命令

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Switch(config)#

Switch(config)#line vty 0 4

Switch(config-line)#password 123456

Switch(config-line)#login   //直接使用密码登录

Switch(config-line)#end

Switch#

方式二:先创建用户名和密码,再进入虚终端应用生效·

Switch>en

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

/* 此处设置密码既可以password创建明文密码,又可以使用secret创建密文密码 */

Switch(config)#username zhangsan password 123456

Switch(config)#line vty 0 4

Switch(config-line)#login local  //使用账户和密码进行登录

Switch(config-line)#end

Switch#

3.配置特权模式密码

Switch#conf  t

Enter configuration commands, one per line.  End with CNTL/Z.

/* 此处设置密码既可以password创建明文密码,又可以使用secret创建密文密码 */

Switch(config)#enable password 123456

//Switch(config)#enable secret 456123

Switch(config)#

如果不设置特权模式密码,远程登陆后无法进入特权模式

如果既设置了password又配置了secret密码,生效的是secret,安全级别更高

1.4 补充VTY介绍

line进入行模式的命令,Console、AUX、VTY、TTY……都是行模式的接口,需要用line配置。VTY是虚拟终端口,使用Telnet时进入的就是对方的VTY口。

路由器上有5个VTY口,分别0、1、2、3、4,如果想同时配置这5口,就line vty 0 4

术语“ vty ”英文全称为Virtual teletype,既虚拟终端,用于获取对设备的Telnet 或 SSH访问,VTY 仅用于设备的入站连接,这些连接都是虚拟的,没有与之关联的硬件。

抽象的“ 0 4 ”表示设备可以同时允许 5 个虚拟连接,可能是 Telnet 或 SSH。在某种程度上,我们可以说 5 (0 – 4) 是路由器或交换机的连接端口,事实上,我们可能有多达 16 个(0 – 15)的连接端口。

1.5 思科设备telnet连接认证方式

no login 不认证

login 直接使用密码登录

login local 使用本地账户密码登录

1.6 总结:Telnet配置流程

  1. 给设备配置IP                                          给设备配置IP 
  2. 进入虚拟终端直接配置密码                     在设备中创建本地用户和密码
  3. 配置enable密码                                       配置enable密码
  4. 进入虚拟终端应用生效login                     进入虚拟终端应用生效login local

1.7 SSH配置思路

1.给交换机虚接口VLAN 1设置IP

Switch>en

Switch#

Switch#conf t

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)#int vlan 1

Switch(config-if)#ip address 192.168.10.2 255.255.255.0

Switch(config-if)#no shutdown

Switch(config-if)#

%LINK-5-CHANGED: Interface Vlan1, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up

2.配置SSH

先查看设备是否支持ssh

Switch#show ip ssh

SSH Disabled - version 1.99

%Please create RSA keys (of atleast 768 bits size) to enable SSH v2.

Authentication timeout: 120 secs; Authentication retries: 3

/* 提示使用ssh V2版本,默认超时120s 登录失败次数3次 */

Switch#

Switch#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

/*针对于ssh连接需要设置一个域名,设置域名之前,不能使用默认主机名 */

Switch(config)#hostname sw1

sw1(config)#

/ * 配置一个域名 * /

sw1(config)#ip domain-name test.com

sw1(config)#

/* 创建密钥对 */

sw1(config)#crypto key generate rsa

The name for the keys will be: sw1.test.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]: 2048  /*密钥长度默认是512,这里使用2048 */

% Generating 2048 bit RSA keys, keys will be non-exportable...[OK]

/* 可以选配设置默认超时、失败认证次数 不配就会使用默认的*/

sw1(config)#ip ssh time-out 100  /* 超时时间 */

sw1(config)#

sw1(config)#ip ssh authentication-retries 5 /* 认证次数 */

3.创建本地用户名和密码

/* ssh严格要求用户名和密码方式认证登录*/

sw1(config)#username zhaoliu secret 123456

4.配置特权模式密码

Switch#conf  t

Enter configuration commands, one per line.  End with CNTL/Z.

/* 此处设置密码既可以password创建明文密码,又可以使用secret创建密文密码 */

Switch(config)#enable password 123456

//Switch(config)#enable secret 456123

Switch(config)#

如果不设置特权模式密码,远程登陆后无法进入特权模式

5.进入vty虚终端,应用生效

sw1(config)#line vty 0 4

sw1(config-line)#login local

sw1(config-line)#

6.在虚拟机中查看效果

 

1.8 总结:SSH配置流程

  1. 设备配置IP
  2. 设备配置SSH(改名、配置域名、配置密钥对)
  3. 创建本地用户密码
  4. 创建enable密码
  5. 进入vty虚终端应用生效login loacl
  • 5
    点赞
  • 27
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

w辣条小王子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值