papai has asked for the wisdom of the Perl Monks concerning the following question:

I recently installed the SCP module on my server, along with it's requirements (SSH and ShellQuote), to perform file copies from one server to the other. I need to change the default port setting, which is currently 22, to 3479. I have tried placing the port number after the hostname, like the following:
$scp = Net::SCP->new( "server1.ca:3479", "user1");
but I get the following error:
ssh: connect to host server1.ca port 22: Connection refused
Is there a setting/parameter that can change this default setting? What do I do?

Replies are listed 'Best First'.
Re: scp & port
by Fletch (Bishop) on Jun 02, 2008 at 13:30 UTC

    Seeing as how this module sits on top of the normal scp command it should be possible to define an alias in your ~/.ssh/config file which specifies the alternate port.

    Host server1-3479 HostName server1.ca Port 3479

    Somewhat kludgy, but it should work.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: scp & port
by tinita (Parson) on Jun 02, 2008 at 13:59 UTC
Re: scp & port
by derby (Abbot) on Jun 02, 2008 at 13:43 UTC

    And another reason to prefer Net::SSH2 ...

    #!/usr/bin/perl use strict; use warnings; use Net::SSH2; my $ssh2 = Net::SSH2->new(); $ssh2->connect( 'webdev', 3479 ) or die; ...

    -derby
      Net::SSH2 is hardly the answer to everything. Libssh2 needs to compile reliably across most platforms before it will become very usable.

      I'm convinced the libssh2 developers just *hate* Solaris.
Re: scp & port
by Khen1950fx (Canon) on Jun 02, 2008 at 15:06 UTC
    Strange. I tried it using the OO interface with named params, and it worked on three different ports for me. Try:

    my $scp = Net::SCP->new( {"host" => 'server1.ca:3479', "user" => 'user +1'} ); $scp->scp($source, $destination);

    updated: added $scp->scp($source, $destination);