问题是:
scp file [email protected]:dst失败,user用户的bashrc文件中加入了 sudo su -,自动切换到root用户。
症状是输入密码验证失败。
rsync, scp是传输文件的工具,会用到stdin和stdout。
login bash会自动执行bashrc中的命令,如果bashrc的命令会输出内容到stdout,需要要求是clean bash。
参考https://rsync.samba.org/FAQ.html#3
is your shell clean
The "is your shell clean" message and the "protocol mismatch" message are usually caused by having some sort of program in your .cshrc, .profile, .bashrc or equivalent file that writes a message every time you connect using a remote-shell program (such as ssh or rsh). Data written in this way corrupts the rsync data stream. rsync detects this at startup and produces those error messages. However, if you are using rsync-daemon syntax (host::path or rsync://) without using a remote-shell program (no --rsh or -e option), there is not remote-shell program involved, and the problem is probably caused by an error on the daemon side (so check the daemon logs).
A good way to test if your remote-shell connection is clean is to try something like this (use ssh or rsh, as appropriate):
ssh remotesystem /bin/true > test.dat
That should create a file called test.dat with nothing in it. If test.dat is not of zero length then your shell is not clean. Look at the contents of test.dat to see what was sent. Look at all the startup files on remotesystem to try and find the problem.