Page 1 of 1

SCP deploy custom port

Posted: Thu Apr 19, 2012 13:37
by jekader
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.

Re: SCP deploy custom port

Posted: Thu Apr 19, 2012 13:56
by jekader
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"].'@';

Re: SCP deploy custom port

Posted: Sat May 12, 2012 15:54
by fgander
Hey

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

Fabian

Re: SCP deploy custom port

Posted: Mon Jun 11, 2012 22:46
by TommyTheKid
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

Re: SCP deploy custom port

Posted: Mon Dec 10, 2012 17:01
by x4FF3
just type -o "Port xxx" works for me ;)

btw viewtopic.php?f=17&t=1056#p3722