Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Specifying identify file with Net::SCP

by Mutant (Priest)
on May 12, 2006 at 14:56 UTC ( #549019=perlquestion: print w/replies, xml ) Need Help??
Mutant has asked for the wisdom of the Perl Monks concerning the following question:


Is it possible to specify an identity file when using Net::SCP? I think it uses the default (whatever keys it can find in $HOME/.ssh) but I'd like to use a key file in a different dir.


Replies are listed 'Best First'.
Re: Specifying identify file with Net::SCP
by idsfa (Vicar) on May 12, 2006 at 18:03 UTC

    Perusing the source, it looks like the command to be executed can be modified:

    use Net::SCP; $Net::SCP::scp = "scp -i $identity_file"; $scp = Net::SCP->new( "hostname", "username" );

    Ultimately, the flag handling should be rewritten in the module to allow full functionality ...

    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. — Cyrus H. Gordon
Re: Specifying identify file with Net::SCP
by socketdave (Curate) on May 12, 2006 at 15:13 UTC
    Net::SCP just wraps the scp program on your system. There doesn't seem to be a way to give options ( -i identify_file here ) to the actual scp binary. There is a $flags variable in the module itself that could be modified to do this, but that would be a bit nasty. Maybe better to modify the module to accept scp options and send a patch back to the author?
Re: Specifying identify file with Net::SCP
by andyford (Curate) on May 12, 2006 at 16:29 UTC
    Assuming that your identity file name stays constant, the quick and easy way would be to specify your alternate id file in your ~/.ssh/config file.

    You can do this on a per-host basis.

    Something like

    Host Box1 IdentityFile /home/goober/.sshalt/id-alt1

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://549019]
Approved by monkfan
NodeReaper does the danse macabre

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-06-23 20:58 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.