使用Telnet/SSH去管理远程设备

一、案例拓扑图

wKiom1UJQ1_SOq0rAAO0VF0uTl8187.jpg


二、为什么我们需要远程登陆?

    很多情况下,你也许不能在设备前使用console线来管理,这时就需要通过telnet或SSH访问其CLI远程管理它,为了能够远程访问,必须先设置虚拟类型终端(VTY);


三、telnet和ssh

  1. Telnet:基于TCP协议,端口号23,是一组提供远程登录方法的程序,所有传输的信息(包括用户名和密码)都是明文的;

  2. SSH:基于TCP协议,端口号22,使用RSA算法对所有传输的信息(包括用户名和密码)进行加密,另一个优点是其传输的数据是经过压缩的,所以可以加快传输的速度,目前SSH存在两种版本(版本1和版本2),版本1有一些加密算法存在漏洞,并且已经被破解,攻击者可以插入数据,版本2修复了这些漏洞,并且版本2可以兼容版本1;


四、实战目的:

    配置sw1,使之能够通过telnet/SSH访问,并且限制只有PC1的IP地址才能够管理。


五、实验步骤

1.首先确保管理客户端能够ping通交换机;
2.先在交换机上配置telnet,并配置密码,使PC能够通过telnet去管理交换机;
3.在交换机上配置,使客户端需要输入用户和密码才能访问到设备;
4.配置ACL,并在vty中调用,限制只有某个IP地址可以访问该设备;

5.在设备上启用SSH协议,并配置客户端通过SSH访问并管理设备;


六、配置命令

1.Telnet配置规则(只需密码)

在PC上(把router当做PC)配置

Router>enable 
Router#configure terminal 
Router(config)#hostname PC
PC(config)#interface fastEthernet 0/0
PC(config-if)#ip address  10.10.10.1 255.255.255.0
PC(config-if)#no shutdown 
PC(config-if)#end
PC#write memory 


在交换机SW1上配置
Switch>enable 
Switch#configure terminal 
Switch(config)#hostname SW1
SW1(config)#enable secret cisco
SW1(config)#enable password cisco  
SW1(config)#interface vlan 1
SW1(config-if)#ip address 10.10.10.254 255.255.255.0
SW1(config-if)#no shutdown                 
SW1(config-if)#exit 
SW1(config)#line console 0
SW1(config-line)#password cisco
SW1(config-line)#login             

SW1(config-line)#exit
SW1(config)#line vty 0 4
SW1(config-line)#password cisco
SW1(config-line)#login                         打开远程登录

SW1(config-line)#end
SW1#write memory 

在PC上测试
PC#telnet 10.10.10.254
Trying 10.10.10.254 ...Open


User Access Verification

Password: 
SW1>enable 
Password: 
SW1#


2.Telnet配置规则(需要用户名和密码)

在交换机SW1上配置

SW1#erase startup-config 
SW1#reload
Switch>enable 
Switch#configure terminal 
Switch(config)#hostname SW1
SW1(config)#enable secret cisco
SW1(config)#enable password cisco  
SW1(config)#interface vlan 1
SW1(config-if)#ip address 10.10.10.254 255.255.255.0
SW1(config-if)#no shutdown 
SW1(config-if)#exit
SW1(config)#line console 0
SW1(config-line)#password cisco
SW1(config-line)#login 
SW1(config-line)#exit
SW1(config)#username cisco password cisco 
SW1(config)#line vty 0 4
SW1(config-line)#login local             配置登录时,使用本地用户名和密码进行验证

SW1(config-line)#access-class 101 in
SW1(config-line)#exit 
SW1(config)#access-list 101 permit ip host 10.10.10.1 any 

在PC上测试

PC#telnet 10.10.10.254
Trying 10.10.10.254 ...Open


User Access Verification

Username: cisco
Password: 
SW1>en
SW1>enable 
Password: 
SW1#


3.SSH配置规则

交换机SW1上的配置

SW1#erase startup-config 
SW1#reload
Switch>enable 
Switch#configure terminal 
Switch(config)#hostname SW1
SW1(config)#enable secret cisco
SW1(config)#enable password cisco  
SW1(config)#interface vlan 1
SW1(config-if)#ip address 10.10.10.254 255.255.255.0
SW1(config-if)#no shutdown 
SW1(config-if)#exit
SW1(config)#line console 0
SW1(config-line)#password cisco
SW1(config-line)#login 
SW1(config-line)#exit
SW1(config)#ip domain-name cisco.com
SW1(config)#crypto key generate rsa 
SW1(config)#ip ssh version 1 
SW1(config)#username cisco password cisco          配置本地用户名和密码

SW1(config)#line vty 0 4
SW1(config-line)#login local 
SW1(config-line)#transport input none
SW1(config-line)#transport input ssh               允许ssh 访问进入 
SW1(config-line)#transport output telnet           允许用telnet去访问其他设备

SW1(config-line)#end
SW1#write memory 


在PC上测试

PC#ssh -l cisco -v 1 10.10.10.254 
Open
Password: 



SW1>enable 
Password: 
SW1#


七、总结

在远程管理设备上配置telnet可以限制只有某个ip能登陆,ssh则没有此功能。


      本文转自独弹古调  51CTO博客,原文链接:http://blog.51cto.com/hunkz/1622199,如需转载请自行联系原作者









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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值