I use such script to view WAN IP on ssh login in the end of /etc/bashrc:

ip_add=$(curl -4s ipconfig.io)
echo "$(tput setaf 1)Current WAN IP is: $(tput setab 7)$ip_add$(tput sgr 0)"

Using echo in a .bashrc will break scp, as scp expects to see its protocol data over the stdin/stdout channels...

While copy from remote remote-server to local you will get such output

[root@homepi:/etc/telegraf]# scp remote-server:/etc/telegraf/telegraf.conf ./
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
protocol error: bad mode

At remote edit /root/.bashrc at remote-server:

####GUS ADDED FROM SCP DOES NOT WORK IF 'ECHO' USED?

if [ -z "$PS1" ]; then
    return
fi

###END GUS

Try again:

[root@homepi:/etc/telegraf]# scp 192.168.100.126:/etc/telegraf/telegraf.conf ./
telegraf.conf                                                                                                                                                                                  100%  183KB 159.2KB/s   00:01    
[root@homepi:/etc/telegraf]# 

Fixed