Rancid 无法下载 Cisco 配置

网络工程 思科
2021-07-30 09:51:15

使用配置了 Rancid 的 CentOS 7。

我正在使用 Rancid 获取我的 Cisco 交换机配置,但似乎 Rancid 无法获取我的配置。我的日志输出:

starting: Seg Out 8 18:47:17 WEST 2018

Trying to get all of the configs.
sw-it-dist-4.cbr.net: missed cmd(s): all commands
sw-it-dist-4.cbr.net: End of run not found
sw-it-dist-4.cbr.net: clogin error: Error: Couldn't login

我的.cloginrc文件:

add user *.net {admin}
add password *.net {PASSWORD_REMOVED} {PASSWORD_REMOVED}
add autoenable *.net            1
add method *.net ssh
add userprompt *.net  {"User Name:"}

当我尝试运行时/usr/local/rancid/bin/clogin sw-it-dist-4.cbr.net,似乎enable缺少命令:

rancid@it-tests logs]$ /usr/local/rancid/bin/clogin sw-it-dist-4.cbr.net
sw-it-dist-4.cbr.net
spawn ssh -x -l admin sw-it-dist-4.cbr.net
Password: 


-----------------------------------------------------------------------------
=============================================================================
==        UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED!!!              ==
==                                                                         ==
==  You must have explicit, authorized permission to access or configure   ==
==  this device. Unauthorized attempts and actions to access or use of     ==
==  this system may result in civil and/or criminal penalties.             
==  All activities performed on this device are logged and monitored.      ==
=============================================================================
-----------------------------------------------------------------------------

sw-it-dist-4>
sw-it-dist-4>

我做错了什么?

例如,如果我clogin手动运行命令,我可以看到我的配置:

[rancid@it-tests rancid]$ /usr/local/rancid/bin/clogin -c "show runn" sw-dc-tor-1.cbr.net.wit
sw-dc-tor-1.cbr.net.wit
spawn ssh -x -l admin sw-dc-tor-1.cbr.net.wit
Password: 

sw-dc-tor-1>enable

Password required, but none set
Password: 
sw-dc-tor-1#
sw-dc-tor-1#terminal length 0
sw-dc-tor-1#terminal width 132
sw-dc-tor-1#show runn
Building configuration...

Current configuration : 10393 bytes
!
! Last configuration change at 13:56:17 UTC Thu Sep 27 2018 by admin
! NVRAM config last updated at 13:46:16 UTC Thu Sep 27 2018 by admin
!
version 15.0
no service pad
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
(...)

但是如果我运行/usr/local/rancid/bin/rancid-run我有这个错误:

[rancid@it-tests logs]$ tailf Switches.20181009.114630 
=====================================
Getting missed routers: round 1.
sw-it-tor-1.cbr.net.wit: missed cmd(s): all commands
sw-it-tor-1.cbr.net.wit: End of run not found
sw-it-tor-1.cbr.net.wit clogin error: Error: Couldn't login
!
=====================================
Getting missed routers: round 2.
sw-it-tor-1.cbr.net.wit: missed cmd(s): all commands
sw-it-tor-1.cbr.net.wit: End of run not found
sw-it-tor-1.cbr.net.wit clogin error: Error: Couldn't login
!

我不明白我错过了什么......


编辑:

感谢你的回复。

我已经更改了autoenable选项,并将其更改hostname.net.wit.

我的.cloginrc文件:

add user *.net.wit {admin}
add password *.net.wit {PASSWORD_REMOVED} {PASSWORD_REMOVED}
add autoenable * 0
add method *.net.wit ssh
add userprompt *.net.wit  {"User Name:"}

现在,如果我运行此命令,/usr/local/rancid/bin/clogin -f /home/rancid/.cloginrc sw-it-dist-4.cbr.net.wit我将得到以下输出:

[rancid@it-tests root]$ /usr/local/rancid/bin/clogin -f /home/rancid/.cloginrc sw-it-dist-4.cbr.net.wit
sw-it-dist-4.cbr.net.wit
spawn ssh -x -l admin sw-it-dist-4.cbr.net.wit
Password: 
-------------------------------------------------------------
===================================
UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED!!!              
===================================
-------------------------------------------------------------
sw-it-dist-4>enable
Password: 
sw-it-dist-4#

但是如果/usr/local/rancid/bin/rancid-run在我的日志中运行我有这个:

[rancid@it-tests logs]$ tailf Switches.20181012.112810 
Trying to get all of the configs.
sw-it-dist-4.cbr.net.wit: missed cmd(s): all commands
sw-it-dist-4.cbr.net.wit: End of run not found
sw-it-dist-4.cbr.net.wit clogin error: Error: Couldn't login

这次我做错了什么?

1个回答

看来您已autoenable在配置中打开,这表明您使用的用户名 ( admin) 已具有“启用”权限。如果您有相反的情况autoenable * 0,RANCID 将enable使用您定义的密码发出命令。

我相信当您手动运行它时它行为不同的原因sw-dc-tor-1.cbr.net.wit是该主机名以“.wit”结尾,因此与*.net您在.cloginrc触发.wit 的主机名不匹配autoenable

http://www.shrubbery.net/rancid/man/cloginrc.5.html