[rancid] .cloginrc add method hostname {ssh:-port} for mtlogin/mtrancid?

Lukasz Sokol el.es.cr at gmail.com
Thu Jun 4 10:43:06 UTC 2015


I added

 send_user "prog: $prog\n methcmd: $methcmd\n suffix: $suffix \nport: $port\n"

under the regex and now I'm seeing:

~$ bin/mtlogin.patched shftedhost
shiftedhost
prog: ssh -p 65122
 methcmd: ssh
 suffix:  
port: 
spawn ssh -i /var/lib/rancid/.ssh/id_ssa_for_mt_backup -c 3des -x -l username+ct shiftedhost
ssh: connect to host shiftedhost port 22: Connection refused

So it /does/ get the -p 65122 from somewhere above?

for comparison, when running with workinghost:

~$ bin/mtlogin workinghost
workinghost
prog: ssh
 methcmd: ssh
 suffix:  
port: 
spawn ssh -i /var/lib/rancid/.ssh/id_ssa_for_mt_backup -c 3des -x -l username+ct workinghost

So If i say the $cmd to be $prog...

set $cmd $prog

it works! for both cases (default and specified port)

Patch inline below. 

--- mtlogin.orig	2015-06-03 17:08:33.642852694 +0100
+++ mtlogin	2015-06-04 11:37:31.085409961 +0100
@@ -323,10 +323,12 @@
 		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. backported from trunk.
+	    # also if port given in method, use it
 	    regexp {ssh(:([^[:space:]]+))*} $prog methcmd suffix port
-	    set cmd $sshcmd
+	    send_user "prog: $prog\n methcmd: $methcmd\n suffix: $suffix \nport: $port\n" # debug line
+	    set cmd $prog
 	    if {"$port" != ""} {
 		set cmd "$cmd -p $port"
 	    }

Please review..



More information about the Rancid-discuss mailing list