SCP deploy custom port

Request new features for NConf

SCP deploy custom port

Postby jekader » Thu Apr 19, 2012 13:37

I'm currently migrating a distributed setup.
All the setings have been imported, the config is deployed locally and icinga is successfully restarted.

Now time to configure deploying configs to collectors, and I'm facing a problem: SSH works on a non-standart port (let's say 4321).
The script first copies the config using scp, then restarts icinga using ssh. But the fact is that port is defined using the -P parameter for scp and -p for ssh.

So if I add "-P 4321" to ssh_options, scp works and ssh does not and vice versa:
scp upload collector config FAILED
Host: mon1
system call OK
scp -r -i /etc/nconf/id_rsa -P 4321 -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 15' /tmp/nconf/ nconf@mon1:/etc/icinga/nconf/
system call FAILED
ssh -i /etc/nconf/id_rsa -P 4321 -o 'StrictHostKeyChecking no' -o 'ConnectTimeout 15' nconf@mon1 "sudo /etc/init.d/icinga reload"
ssh: connect to host 4321 port 22: Invalid argument

So I propose adding a ssh_port directive to set the port if it's not the default one.

Maybe someone can propose a workaround for this situation, I think I'm not the only one using custom SSH ports.
jekader
beginner
beginner
 
Posts: 10
Joined: Fri Mar 30, 2012 07:59

Re: SCP deploy custom port

Postby jekader » Thu Apr 19, 2012 13:56

and here's a quick two line patch against nconf 1.3.0 that implements what I mentioned above:

nconf/include/modules/deployment/scp/class.deployment_scp.php
Code: Select all
[root@mon3 scp]# diff -u class.deployment_scp.php.orig class.deployment_scp.php
--- class.deployment_scp.php.orig       2012-04-02 12:40:00.000000000 +0300
+++ class.deployment_scp.php    2012-04-19 14:54:27.095050829 +0300
@@ -38,6 +38,7 @@

         // additional options
         // options must be complete like "-o ssh_option" or "-l limit"
+        if (!empty($host_infos["ssh_port"]) ) $command .= ' -P '.$host_infos["ssh_port"];
         if (!empty($host_infos["ssh_options"]) ) $command .= ' '.$host_infos["ssh_options"];

         // source file
@@ -62,6 +63,7 @@
             }

             // options must be complete like "-o ssh_option" or "-l limit"
+            if (!empty($host_infos["ssh_port"]) ) $ssh_command .= ' -p '.$host_infos["ssh_port"];
             if (!empty($host_infos["ssh_options"]) ) $ssh_command .= ' '.$host_infos["ssh_options"];

             if (!empty($host_infos["user"]) ) $ssh_command .= ' '.$host_infos["user"].'@';
jekader
beginner
beginner
 
Posts: 10
Joined: Fri Mar 30, 2012 07:59

Re: SCP deploy custom port

Postby fgander » Sat May 12, 2012 15:54

Hey

nice finding, thanks for the patch , I will try to fix this in a next version.

Fabian
F.G. - NConf developer
http://www.nconf.org
Image
Follow NConf on Twitter!
User avatar
fgander
NConf developer
NConf developer
 
Posts: 308
Joined: Mon Mar 16, 2009 14:23
Location: Bern, Switzerland

Re: SCP deploy custom port

Postby TommyTheKid » Mon Jun 11, 2012 22:46

In the mean time, you can get by using ~apache/.ssh/config

Port 4321

"man ssh_config" for details

Note: if your "web server" user is not apache, you may have to adjust that filename above slightly :)

Tommy
TommyTheKid
starter
starter
 
Posts: 3
Joined: Mon Jun 11, 2012 22:40

Re: SCP deploy custom port

Postby x4FF3 » Mon Dec 10, 2012 17:01

just type -o "Port xxx" works for me ;)

btw viewtopic.php?f=17&t=1056#p3722
x4FF3
starter
starter
 
Posts: 4
Joined: Tue Jan 17, 2012 16:13


Return to Feature requests

Who is online

Users browsing this forum: No registered users and 1 guest

cron