Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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
shmem puts down the Canon garments and dresses as Chancellor
[vrk]: Congratulations. You should have Cookies
[shmem]: thanks vrk - but I'll rather have a plate of "silly con charme"
Lady_Aleena is trying to explain perl regexen to people right now and explaining how variables expand in regexen.
[Lady_Aleena]: The people I'm talking with think /$var/ looks weird with some saying it shouldn't work.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-04-28 09:41 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (520 votes). Check out past polls.