Reputation: 5074
I've got a script that copy some content from local to remote, where remote is given as an input argument.
To do so, I'm using scp
and it also support local copy (meaning that the remote given as input matches the local).
I wonder if it worth the effort to change the script so that in this special case, cp
will be called rather than scp
. perhaps do you know if the internal implementation of scp
do this for me ?
Upvotes: 0
Views: 588
Reputation: 21965
Instead of worrying about which is faster, why not implement some branching inside the script
if [ "$1" = "local" ]
then
#Use cp
else
#Use scp
fi
That said, scp
should be slower than cp
for the manpage says :
scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
The overhead in scp
is the time taken in authenticating the host and guest before a transfer occurs.
But you can use the -o NoHostAuthenticationForLocalhost
option with scp
as a workaround.
scp -o NoHostAuthenticationForLocalhost target destination
should be as fast as cp
Upvotes: 2