Echo in remote bashrc is causing scp to fail

Hi,

I’m trying to scp some files over to a remote host, however it seems to be failing as the /etc/bash.bashrc.local prints some extra lines when it detects a remote session. Here’s the contents of that file:


# Terminal colours
lightcyan="\e[0;36m"
reset="\e[m"
# SSH colour
if [ -n "$SSH_CONNECTION" ];
  then
     _IP=$SSH_CONNECTION; _IPa=(${_IP// / });
     echo -e "
Welcome to $lightcyan${HOST}$reset (${_IPa[2]}:${_IPa[3]})";
     echo -e "You are connecting from ${_IPa[0]}
";
     PS1="\$lightcyan\]${PS1}\$reset\]";
     unset _IP _IPa
fi;

scp’ing a file gives this:


ak@i-ghost:~> scp file.sh laptop:/home/ak/bin


Welcome to suse-laptop (10.2.10.197:22)
ak@i-ghost:~>

I know the echos are a problem, as commenting them out temporarily fixed the issue, as seen here:


ak@i-ghost:~> scp file.sh laptop:/home/ak/bin
file.sh                                                                                                          100%   84     0.1KB/s   00:00    
ak@i-ghost:~> 

Is there any way around this?

Thanks in advance.

Never mind, got it fixed thanks to a knowledgeable friend elsewhere.

I left the $PS1 colourizing in bashrc.local, and moved the motd stuff into profile.local. I then disabled the sshd motd (and moved the default line into profile.local instead). The scp is working fine now.

Also for reference, this works as in the OP on OpenSSH_6.0p1, OpenSSL 1.0.1c 10 May 2012 running on Arch according to the aforementioned friend. So I guess it’s a bug or some configuration in suse/bash. I’m running OpenSSH_5.8p2, OpenSSL 1.0.0e 6 Sep 2011 which is the latest in the default repos I think.

This thread can now be closed.

Only print a welcome message if the shell is going to be interactive.


case "$-" in
*i*)
# Terminal colours
lightcyan="\e[0;36m"
reset="\e[m"
# SSH colour
if [ -n "$SSH_CONNECTION" ];
  then
     _IP=$SSH_CONNECTION; _IPa=(${_IP// / });
     echo -e "
Welcome to $lightcyan${HOST}$reset (${_IPa[2]}:${_IPa[3]})";
     echo -e "You are connecting from ${_IPa[0]}
";
     PS1="\$lightcyan\]${PS1}\$reset\]";
     unset _IP _IPa
fi;
;;
esac