我正在尝试将文件从本地机器传输到远程机器。
当我scp
不带-v
选项使用时,它只提供以下输出:
.--. or '\033[0;1;33;93m.-\033[0;1;32;92m-.\033[0m'
Run Code Online (Sandbox Code Playgroud)
当我尝试scp
使用-v
选项时,我得到以下输出,似乎文件传输成功:
——
$ scp -v file.sh user@IP:/home/user/foo
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_PAPER = tr_TR.UTF-8
debug1: Sending env LC_ADDRESS = tr_TR.UTF-8
debug1: Sending env LC_MONETARY = tr_TR.UTF-8
debug1: Sending env LC_NUMERIC = tr_TR.UTF-8
debug1: Sending env LC_ALL = en_US.UTF-8
debug1: Sending env LC_TELEPHONE = tr_TR.UTF-8
debug1: Sending env LC_IDENTIFICATION = tr_TR.UTF-8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_MEASUREMENT = tr_TR.UTF-8
debug1: Sending env LC_CTYPE = UTF-8
debug1: Sending env LC_TIME = tr_TR.UTF-8
debug1: Sending env LC_NAME = tr_TR.UTF-8
debug1: Sending command: scp -v -t /home/user/foo
.--.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
Transferred: sent 2504, received 2668 bytes, in 1.7 seconds
Bytes per second: sent 1510.2, received 1609.1
debug1: Exit status 0
Run Code Online (Sandbox Code Playgroud)
请在此处查看sshd_config
文件。请注意,我可以进入远程机器。也返回。ssh
ssh user@IP pwd
/home/user
[Q] scp
成功传输文件,但它没有显示在远程机器上。这可能是什么原因,我该如何解决?
小智 7
确保您的 shell 中没有将数据回显到终端的启动脚本。这可能在.bashrc
或.profile
当 scp 连接到远程主机时,它希望看到 SSH 服务器标头,然后是打开的 stdin 流。
如果远程主机上的 .profile 响应任何输出,则会导致 scp 静默失败。如果是这种情况,您可能需要删除它或设置保护条件以确保在没有控制 tty 设备的情况下不会打印任何内容。请参阅tty
命令。