3

I am connecting from bastion (server-name) to another server (ecash) through ssh via a key pair.

I have to copy a file called htdocs from ecash to bastion, so I am running:

scp source_user@source_remote_host:/usr/bin/mysql_backup.sh \
     target_user@target_remote_host:/var/tmp/

but that's asking me for a password, even though I was connected through a key pair.

And when I enter the password, I get permission denied error (publickey, keyboard-interactive).

Is there issue in the command or file permissions? What can I do?

2
  • As far as I can tell, with this syntax, target_remote_host will see an incoming connection from source_remote_host (which may not be what one expects). So I guess you don't have the neccessary private keys on source_remote_host? Maybe things will be better if you allow ssh agent forwarding on source_remote_host. Sep 27, 2016 at 10:27
  • i want to copy folder htdocs from ecash-server under directory /var/www/localhost/htdocs to baston-server in any directory. please check my scp command is right ? or how will be scp root@ecash-staging:/var/www/localhost/htdocs. /home
    – Waqas Rana
    Sep 27, 2016 at 10:33

2 Answers 2

2

but that's asking me for a password, even though I was connected through a key pair.

Using this syntax is connecting from the first host (not from your host) to the second. You can authenticate from your host using -3 switch, which is usually more convenient:

scp -3 source_user@source_remote_host:/usr/bin/mysql_backup.sh \
    target_user@target_remote_host:/var/tmp/
3
  • 1
    Let's hope there never is a protocol version 3, and no protocol version 4 until IPv4 is deprecated. ;) Sep 27, 2016 at 11:41
  • There will be SSH protocol 3, but it will probably not have this switch for scp.
    – Jakuje
    Sep 27, 2016 at 11:42
  • i used this command that worked for me . rsync -avp ssh --progress /home/root@ecash-staging:/var/www/localhost/htdocs
    – Waqas Rana
    Sep 27, 2016 at 12:17
1

I used this command that worked for me:

rsync -avp ssh --progress /home/ root@ecash-staging:/var/www/localhost/htdocs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .