-
设置口令
-
设置安全外壳(SSH)
-
会话管理
命令模式 | 用途描述 |
---|---|
Router# enable Router# config terminal |
从用户模式进入特权模式 进入配置模式 |
hostname R1 no ip domain-lookup enable password desen enable secret desen301 service password-encryption |
设置设备名称为R1 关闭动态域名解析 设置启用口令为desen 设置加密口令为desen301,替代启用口令 启用密码加密服务 |
R1(config)# line console 0 | 进入console 0口 |
no exec-timeout logging synchronous password cisco7200 login |
关闭会话超时 启用日志同步,以免弹出不必要的日志信息 设置console登陆口令为cisco7200 启用认证功能,如果没有设置线路密码则该线路不使用 |
R1(config-line)# exit R1(config)# line vty 0 1869 |
退出console 0配置模式 进入VTY线路0到1869 |
password telnet1869 login no login |
设置telnet密码为telnet1869 启用VTY认证功能 关闭VTY认证功能,可直接telnet |
R1(config-line)# exit | 退出vty线路配置模式 |
R1(config)# interface fastEthernet 0/0
R1(config-if)# ip address 192.168.1.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# ip domain-name desenpast.com
# 设置域名(生成加密密码需要用到用户名和域名)
R1(config)# username desen password cisco
R1(config)# crypto key generate rsa general-keys modulus 2048
# 生成一个2048位rsa算法的密钥
R1(config)# ip ssh time-out 60
# 设置最大空闲时间为60秒
R1(config)# ip ssh authentication-retries 2
# 最大失败尝试次数为2
R1(config)# line vty 0 1869
R1(config-line)# transport input ssh
# 设置ssh为vty线路协议
R1(config-line)# login local
# 使用本址认证(可以不设置vty线路密码)
客户端连接
R2# ssh -l desen 192.168.1.1
# SSH登陆192.168.1.1,用户名为desen
Password: cisco
R1# enable
Password: desen301
# 输入加密密码
查看设备在线用户:show users
关闭vty线路0的会话:clear line vty 0
查看当前建立的远程会话:show sessions
断开远程会话ID为226的会话线路:disconnect 226