[rancid] .cloginrc add method hostname {ssh:-port} for mtlogin/mtrancid?
Michael Newton
mnewton at pofp.com
Wed Jun 3 16:42:25 UTC 2015
If you’re looking to connect to a custom port number, this is what we do. Not sure if you can use it or not, but thought it might help someone.
/var/rancid/foo/router.db:
host.example.com:2222;hp;up;HP switch 22
host.example.com:3222;aruba;up;Aruba switch 32
/var/rancid/.cloginrc:
add sshcmd * {/usr/local/bin/sshport}
/usr/local/bin/sshport:
#!/bin/sh
#host is the last argument passed
FULLHOST=${!#}
#check it for the colon
if [ -z "${FULLHOST##*:*}" ]
then
#stuff left of colon
HOST=${FULLHOST%:*}
#stuff right of colon
PORT=${FULLHOST#*:}
else
HOST=$FULLHOST
PORT=22
fi
#now remove the original host from the arguments list
#??? magic!
ARGS=( "$@" )
unset ARGS[${#ARGS[@]}-1]
ARGS=${ARGS[@]}
/usr/bin/ssh -p $PORT $ARGS $HOST
--
Michael Newton
Director, Product Development
Point of Presence Technologies
From: Rancid-discuss on behalf of Lukasz Sokol
Date: Wednesday, June 3, 2015 at 9:04 AM
To: "rancid-discuss at shrubbery.net"
Subject: Re: [rancid] .cloginrc add method hostname {ssh:-port} for mtlogin/mtrancid?
On 03/06/15 16:42, Lukasz Sokol wrote:
On 03/06/15 16:08, heasley wrote:
Wed, Jun 03, 2015 at 03:07:39PM +0100, Lukasz Sokol:
rancid at george:~$ bin/mtlogin hostname
hostname
Error: unknown connection method: ssh:65122
will get there, eventually :)
grumble. it needs to match the port below; i think this change is the
missing bit. sorry
Index: bin/mtlogin.in
===================================================================
--- bin/mtlogin.in (revision 3124)
+++ bin/mtlogin.in (working copy)
@@ -277,7 +277,7 @@
send_user "\nError: telnet failed: $reason\n"
return 1
}
- } elseif ![string compare $prog "ssh"] {
+ } elseif [string match "ssh*" $prog] {
# ssh to the router & try to login with or without an identfile.
regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
set cmd $sshcmd
I found the relevant line next to the previous backport,
but this change causes all ssh contacts to fail even the 'up' test.
what is wrong with compare ?
lukasz
would this mean that the default ssh method would need to be {ssh:22} with this change?
so that the one with {ssh:65122} will be an exception ?
or might the order of 'regexp {...} methcmd suffix port' matter then?
sorry for stabbing in the dark :)
lukasz
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss at shrubbery.net
http://www.shrubbery.net/mailman/listinfo/rancid-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20150603/b696ef27/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5966 bytes
Desc: not available
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20150603/b696ef27/attachment.bin>
More information about the Rancid-discuss
mailing list