Scp Via Another Server

Home » CentOS » Scp Via Another Server
CentOS 13 Comments

I normally use SSH to log into a remote server, change directory and then use scp from there to copy files from another remote server to the first one.

Now the first server has been hit by continuous error correction messages from the ECC controller, all of which are corrected, and I am unable to get a command line to issue the required commands to change directory and then run scp from the other server. I have no problems, however, getting into the first server – except for being drowned by the error correction messages and the server seems to be running “fine”.

Until I am able to get to the server and investigate, is it possible to accomplish the above on a single command line, thus avoiding seeing the error messages? I should add that both the first and second server are set up to accept keys and not passwords so at least I don’t have to worry about that.

Thank you.

13 thoughts on - Scp Via Another Server

  • $ scp svr2:/path/to/source svr1:/path/to/dest

    You’ll get twice the network traffic since the copy is running on your workstattoin (or whatever).

    —–BEGIN PGP SIGNATURE—

  • This did not work even though the same user is authenticated on both servers and I have no problems ssh’ing into either of the two servers. The message is “permission denied.”

    Presumably some problem with being recognized on both systems?

  • It sounds like it. Try:
    $ SSH svr1 pwd
    $ SSH svr2 pwd If they work without asking for a password then there is a deeper configuration issue. If you do get prompted for a password then you need to sort out your access. If the username differs try
    @ both for the SSH test and the scp command.
    —–BEGIN PGP SIGNATURE—

  • I don’t know. I have no problems with ‘ssh user1@server1’ and ‘ssh user1@server2’ or running ‘scp user1@server2:somefilesserver2 tolocationonserver1’ after having ssh’ed into server 1.

    I just tried ‘ssh user1@server1 ‘scp user1@server2:somefilesserver2 tolocationonserver1” which worked fine suggesting that the configuration is correct.

    There seems to be something broken when using scp between two remote locations. Some posts on the ‘net suggest using ‘scp -3’ to do an intermediate copy to the workstation between the two remote servers but that option does not seem to have been implemented yet on scp for CentOS 6.7.

  • Try changing kernel console log level to 0, possibly:

    echo ‘0 0 0 0’ > /proc/sys/kernel/printk

    should take effect instantly. You _might_ be able to do this remotely via ssh. Also possibly can do via magic sysrq + 0.

    (see: RHEL 6 Deployment Guide (rev 3.1 2011-05-19) Appendix C pp.537-538)

    HTH, HAND,

  • Ah, ignore my earlier comment then. ‘scp -3’ is not available in the OpenSSH in CentOS6. It appears to have been introduced in OpenSSH 5.7, and CentOS6 uses 5.3.


    Jonathan Billings

  • I must say I haven’t needed the -3 myself, but perhaps I’ve just been lucky. Martin
    —–BEGIN PGP SIGNATURE—

  • Hi,

    This is fairly common. I would look into the use of a proxy command to do exactly what you ask. In addition, though not strictly necessary, I also would generally recommend rsync rather than scp*. Both of these are documented on my page here:

    http://www2.physics.ox.ac.uk/it-services/central-ssh-access

    Its got an Oxford Physics specific slant to it but hopefully its helpful.

    *I don’t think rsync has any issue when the remote machine prints things either.

    Sean