How To: Troubleshoot SCP Command

Some times we face problems in transferring the data from one machine to other machine using scp. Actually the scp command is executed successfully but the data is not transferred. As the .bashrc and not the .bash_profile file of the system to which the data is being transferred is executed. If the .bashrc of the remote system contains any command or executable which output some data to the standard output then that command is executed and the output is flushed on the local machine and the scp command is terminated and data is not transferred.

For example if the remote machine has any ‘echo’ or ‘nfrm’ command in .bashrc file, the scp of the data will not be possible.
Also suppose the remote machine has a lines in .bashrc like this


where contains the data as below:-

echo "Kulbir Saini"

Then also the scp will not be possible.

So if you are facing such problems please try to remove such lines from your .bashrc file and scp the data you want.
Anyway you can keep those lines in your .bash_profile because it is not executed while transferring the data.

Please report any other cases in which scp is not possible.


2 thoughts on “How To: Troubleshoot SCP Command

  1. Hey, I bumped into the same problem too! Did you find out exactly what happens “under the hood” of scp that leads to this? Or, did you find a way to tell from within .bashrc that it is being executed for scp and therefore should stop babbling non-sense to standard output?


Comments are closed.