思科认证CiSCO交换机配置与SSH登陆操作命令详解本⽂实例讲述了思科认证CiSCO 交换机配置与SSH 登陆操作命令。分享给⼤家供⼤家参考,具体如下:
题⽬:在三层交换机上仅运⾏ SSH 服务,且⽤户名和密码的⽅式登录交换机。
(⼀)了解主机名与域名
1、"主机名" 为该设备的名称
2、"域名" 为该设备所属的所属者
(⼆)配置主机名与域名
1、进⼊特权模式
ESW1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
2、配置主机名
ESW1(config)#hostname rabbit
rabbit(config)#
3、配置域名
rabbit(config)#ip domain-name ?
WORD  Default domain name
vrf  Specify VRF
rabbit(config)#ip
rabbit(config)#do show ip domain-name
<
(三)了解什么是 line
1、”line“ 命令有多个选项参数
rabbit(config)#line ?
<0-198>  First Line number
aux      Auxiliary line
console  Primary terminal line
tty      Terminal controller (终端控制器)
vty      Virtual terminal (虚拟控制器)
x/y      Slot/Port for Modems
2、”who“ 查看当前⾃⼰所在位置
rabbit(config)#do who
Line      User      Host(s)              Idle      Location
*  0 con 0                idle                00:00:00
(四)配置 line 选项卡
1、建⽴ ssh ⽤户
rabbit(config)#aaa new-model
The aaa new-model command causes the local username and password on the router
rabbit(config)#username cisco password 0 cisco
2、配置 ssh 密码
rabbit(config)#crypto key zeroize rsa
清空 rsa 模式的 crypto 密码
rabbit(config)#crypto key generate rsa
rabbit(config)#ip ssh version 2
rabbit(config)#do show ip ssh
SSH Enabled - version 2.0
Authentication timeout: 120 secs; Authentication retries: 5
3、配置⼀些信息
rabbit(config-line)#exit
rabbit(config)#ip ssh ?
authentication-retries  Specify number of authentication retries ( 指明 authentication 尝试次数 )
break-string            break-string
logging                Configure logging for SSH
maxstartups            Maximum concurrent sessions allowed
port                    Starting (or only) Port number to listen on
rsa                    Configure RSA keypair name for SSH
source-interface        Specify interface for source address in SSH
connections
time-out                Specify SSH time-out interval (指明 SSH 超时间隔)
version                Specify protocol version to be supported ( sshv2 Or sshv1 )
4、配置 vty 传输模式
rabbit(config)#line vty 0
VTY是路由器的远程登陆的虚拟端⼝,0 4表⽰可以同时打开5个会话。
rabbit(config-line)#transport input ssh
rabbit(config-line)#
5、配置⽤户上线后特权模式密码
rabbit(config)#enable secret 0 password
rabbit(config)#enable password 0 password
故障排除提⽰
如果 SSH 配置命令被作为⾮法命令拒绝,则说明您没有成功地为路由器⽣成 RSA 密钥对。请确保指定了主机名和域。
然后,使⽤ crypto key generate rsa 命令⽣成 RSA 密钥对并启⽤ SSH 服务器。
配置 RSA 密钥对时,可能会遇到下列错误消息:
1. No hostname specified
此时,必须使⽤ hostname 全局配置命令为路由器配置⼀个主机名。
2. No domain specified
此时,必须使⽤ ip domain-name 全局配置命令为路由器配置⼀个主机域。
允许的 SSH 连接数受为路由器配置的 vty 的最⼤数⽬限制。每个 SSH 连接使⽤⼀个 vty 资源。
SSH 使⽤本地安全协议或通过路由器上的 AAA 配置的安全协议进⾏⽤户⾝份验证。配置 AAA 时,必须通过在全局配置模式下应⽤关键字来禁⽤控制台上的 AAA,确保控制台不在 AAA 系统下运⾏。
No SSH server connections running.
carter#show ssh
%No SSHv2 server connections running.
%No SSHv1 server connections running.
此输出表明 SSH 服务器被禁⽤或未正确启⽤。如果已经配置了 SSH,建议您在设备中重新配置 SSH 服务器。完成下列步骤在设备上重新配置 SSH 服务器。
1. 删除 RSA 密钥对。在删除 RSA 密钥对后,SSH 服务器将⾃动禁⽤。
carter(config)#crypto key zeroize rsa
注意:当您启⽤SSH v2时,⽣成与⾄少768的⼀密钥对作为⽐特⼤⼩是重要的。
警告:在保存配置后,此命令将⽆法撤消。⽽且,在删除 RSA 密钥对后,您不能使⽤证书或 CA 与其他 IP 安全(IPSec) 对等体进⾏证书交换,除⾮您通过重新⽣成 RSA 密钥、获取 CA 的证书并再次请求⾃⼰的证书重新配置CA 互操作性。有关此命令的详细信息,请参阅crypto key zeroize rsa - Cisco IOS 安全命令参考 12.3 版。
2. 重新配置设备的主机名和域名。
carter(config)#hostname hostname
carter(config)#ip domain-name domainname
3. 为路由器⽣成 RSA 密钥对,这将⾃动启⽤ SSH。
carter(config)#crypto key generate rsa
有关此命令⽤法的详细信息,请参阅。
注意:您可能会收到如下错误消息:SSH2 0:Unexpected mesg type received,这是因为路由器⽆法理解接收到的数据包。要解决此问题,请在⽣成⽤于 SSH 的 RSA 密钥时增加密钥长度。
4. 配置 SSH 服务器。为了启动并设定⼀Cisco路由器/交换机SSH服务器的,您能配置SSH参数。如果不配置 SSH
参数,将使⽤默认值。ssh命令指定端口
ip ssh {[timeout seconds]|
[[authentication-retries integer]}
carter(config)# ip ssh
有关此命令⽤法的详细信息,请参阅ip ssh - Cisco IOS 安全命令参考 12.3 版。