I need to scp and then ssh to the same host. Is it possible to authenticate just one time? Is it possible to input password once, then scp file, then ssh on that host and work interactively?
Update
I get HOSTNAME and SSH_PASSWORD. I never log in on that machine before. I need to send some files (probably using scp) and then log in using ssh and work on that HOST interactively. I want to save time and input password just once. I have lots of such hosts...
#/usr/bin/perl
use strict;
use warnings;
use Net::OpenSSH;
$ssh = Net::OpenSSH->new(host => '...', user => '...', password => '...');
$ssh->scp_put('/local/path/to/file', '/remote/path/to/file');
$ssh->system();
There are 3 ways to achieve this:
1 - The proper way:
2 - Doing it with expect:
3 - Use pscp instead of scp:
sudo apt-get install putty-toolspscp -scp -pw $password $file_path $login@$IP:$dest_dirIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With