一、telnet工作原理

图片.png

二、图解(SW1管理SW3、需在SW3上配置静态路由

wKiom1dWzOSgUIc5AAA0LySWZu4110.jpg

在设备升级时、PC1用户无法正常使用、PC2正常、需删除原有的MAC地址和网关的绑定关系


第三步、配置步骤

H3C配置telnet步骤

info-center enable    开启日志系统
undo info-center enable  关闭日志系统
info-center synchronous 打开命令行输入回显功能

password-control enable #慎用
password-control login-attempt 3 exceed lock-time 1   登录尝试次数三次 则等1分钟在登录

acl number 3000   acl条目
rule 0 permit tcp  允许tcp访问
rule 5 permit tcp source host 192.168.1.1 any destination-port eq 23    允许192.168.1.1 访问任何的22端口

telnet server enable   #开启telnet服务
local-user admin  #创建用户
password simple 123  #为用户设置密码
authorization-attribute level 3   设置用户拥有的权限

service-type telnet   #为用户定义服务类型
service-type terminal level 3   #开启console登陆密码模式

图片.png

user-interface vty 0 4
authentication-mode scheme   #认证模式

protocol inbound telnet  #连入协议只允许telnet

acl 3000 inbound   #允许acl 3000访问

idle-timeout 1 30  设置超时时间为1分钟30秒。
idle-timeout minutes10  10分钟无操作自动断开连接
idle-timeout seconds10  10秒钟无操作自动断开连接

lock lock-timeout timeout 锁定超时时间

idle-timeout    超时时间默认为10分钟

auto-execute command telnet 192.168.1.2     192.168.1.2 登录不需要密码可以直接登录

escape-key a   按a终结ping

设置console登录

user-interface aux 0  
authentication-mode password   #登录密码

activation-key s  #按s进入console配置界面
user-interface console 0
undo authentication-mode #在Console用户界面下取消Console密码

配置SSH步骤

rsa local-key-pair create #生成本地密钥对
public-key local create rsa  #配置非对称密钥生成本地公钥

password-control enable #SSH用户的验证方式为Password、RSA方式

ssh server enable   开启ssh服务
ssh user admin service-type stelnet authentication-type 配置用户admin的服务类型为stelnet 认证方式为
ip ssh version 2  默认是1.99版本
ssh server timeout 1 设置ssh超时时间
ssh server authentication-retries 3 设置ssh验证重试次数

domain 必须有一个域名生成自己的key(RSA自签名的key)

华为SSH配置步骤

本地Console、Telnet登录

[Switch]header login information "welcome to my device" 配置在用户登录前显示的标题消息

[Switch]header shell information "Welcome to the Huawei certification lab" 配置在用户登录后显示的标题消息

[Switch]telnet server enable  #打开telnet服务

[Switch] aaa

[Switch-aaa] undo local-aaa-user password policy administrator #关闭首次telnet登陆修改(S57系列)

[Switch-aaa] undo local-user policy security-enhance #关闭本地用户账户安全策略功能
[Switch-aaa] undo local-user policy password complexity-enhance  #关闭本地用户密码复杂度功能
[Switch-aaa] undo user-name minimum-length  #关闭新建本地用户最小长度的功能
[Switch-aaa] undo local-user policy password change  #关闭下次登录提醒修改原始密码的功能   

[Switch-aaa] local-user admin password irreversible-cipher Hello@123 #本地用户admin,密码为Hello@123
[Switch-aaa] local-user admin privilege level 15 #用户级别为15级。
[Switch-aaa] local-user admin service-type terminal #接入类型为terminal,即:Console用户
[Switch-aaa] local-user admin service-type telnet #接入类型为telnet,即:Telnet用户

[Switch-aaa] local-user authentication lock times 3 5 #配置5分钟内,本地账号认证失败次数限制为3

[Switch-aaa] local-user authentication lock duration 3 #配置本地账号自动解锁时间间隔为3分钟

[Switch-aaa] quit
[Switch] user-interface console 0
[Switch-ui-console0] authentication-mode aaa #Console认证方式为AAA认证
[Switch-ui-console0] quit
[Switch] acl 2008
[Switch-acl-basic-2008] rule permit source 10.1.1.1 0.0.0.0
[Switch-acl-basic-2008] quit
[Switch] user-interface vty 0 4  
[Switch-ui-vty0-4] user privilege level 15 #用户级别为15级
[Switch-ui-vty0-4] authentication-mode aaa #认证方式为AAA认证
[Switch-ui-vty0-4] protocol inbound telnet #支持的协议为Telne
[Switch-ui-vty0-4] acl 2008 inbound  #只允许满足ACL 2008规则的用户登录本设备  
[Switch-ui-vty0-4] quit

[Switch]quit

<Switch>terminal monitor #开启终端显示信息中心发送信息的功能
<Switch>terminal trapping #打开屏显告警,不再有该告警产生
<Switch>terminal logging #开启终端显示Log信息功能


配置STelnet登录(SSH)
<HUAWEI> system-view
[HUAWEI] sysname Switch
[HUAWEI] dsa local-key-pair create #生成本地DSA密钥对(加密使用的公钥)
[Switch] stelnet server enable #开启STelnet服务器功能
[Switch] user-interface vty 0 4  #5个线路配置

[Switch-ui-vty0-4] user privilege level 15 #设置用户权限为15
[Switch-ui-vty0-4] authentication-mode aaa #调用AAA认证模式

[Switch-ui-vty0-4] protocol inbound ssh #将远程登录的连入协议配置为只允许ssh

[Switch-ui-vty0-4] history-command max-size 20 #历史命令记录最大条目
[Switch-ui-vty0-4] idle-timeout 1 30  #闲置超时时间为1分30秒
[Switch-ui-vty0-4] screen-length #设置屏显长度

[Switch-ui-vty0-4] undo shell 设置在虚拟终端(VTY)0到4上终止终端服务

[Switch-ui-vty0-4] quit
[Switch] ssh user admin authentication-type password  #用户admin的认证方式为Password认证
[Switch] ssh user admin service-type stelnet  用户admin的服务方式为STelnet
[Switch] ssh authentication-type default password 多个SSH用户使用Password认证方式,该命令简化配置

[Switch] ssh server authentication-retries 4

[Switch] ssh server ip-block disable

[Switch] ssh client first-time enable 第一次使用ssh登录时,启用ssh客户端

图片.png

设置WEB管理端口

ip http enable    开启http
ip http port 8080  开启http8080端口
ip http acl 2000   配置HTTP服务与ACL 2000关联

display tcp status #查看当前建立的所有TCP连接情况
http server permit interface g0/0/0 配置允许访问Web网管的接口。 缺省情况下,允许设备上所有接口访问Web网管

display current-configuration filter http server #查看是否有http server permit interface的配置
display current-configuration filter traffic-filter inbound acl   #查看traffic-filter inbound acl acl-number的配置


display http server
HTTP server status    : Enabled #(default: disable)
HTTP server port      : 80   #(default: 80)
HTTP timeout interval : 10 #(default: 10 minutes)
Current online users  : 5 #当前在线用户数
Maximum users allowed : 5 #允许访问的最大用户数
HTTPS server status   : Enabled #(default: disable)
HTTPS server port     : 443  #(default: 443)
HTTPS SSL Policy      : default_policy


最后测试,检查一下

telnet 127.0.0.1 #检查配置结果
display users 查看登录用户
display user-interface 查看登录用户
display telnet server status #检查SSH Server是否开启

display user-interface maximum-vty #查看VTY界面允许登录的最大用户数,确认当前的VTY通道是否全部被占用

free  user-interface vty 0  释放远程登陆用户

kill user-interface { ui-number | ui-type ui-number1 }#清除在线用户

<Ctrl+T>快捷键——客户端主动断开telnet连接

Ctrl + C组合键退出会话模式
Ctrl + shift + 6 中断ping、tracrt命令


Cisco配置:
switch(config)# no logging event link-status #关闭接口状态日志信息
switch(config)# user-interface console 0
authentication-domain domain-name #设置使用的认证域名称

undo terminal monitor #关闭console下的打印信息
logging synchronous  配置console日志同步,输入命令的时候不被一些日志信息打断
logging console warnings 只有4级以下的日志消息显示到控制台上,默认记录所有日志信息
authentication-mode local user admin password cipher Admin@123
lock authentication-count 5 #默认值为3次,可修改为1~5
lock lock-timeout 20 #默认10分钟