I think I see part of the problem - When you are doing an scp you are not initializing
a terminal interface.
Normally, this isn't a problem - but if the login/profile output things ASSUMING a
terminal connection, then things can get strange.
It just will work if you use ssh (terminal is connected). scp may work for
some versions (where the client ignores/recognizes that terminal output is present)
but... not recommended.
Usually conditional output to a terminal is bracked by something like
if [ "$PS1" ne "" ]; then
<send stuff to the terminal, set terminal characteristics...>
This prevents trying to set things that don't exist, and cause an error response
from the shell - which in turn may be misinterpreted by the daemon that executes
This is particularly noticable with rsh/krsh (remote shell) and rcp/krcp (remote copy).
Part of the reason for the problem is that rcp/krcp and scp are designed to perform
an optimized transfer when given a command like:
scp remotehost:remote_file remotetarget:remote_file
I believe scp establishes the equivalent of:
ssh remotehost scp remote_file remotetarget:remote_file
for the purpose of copying a file from one remote host to another.