Scp

scp 將文件成功傳輸到主機但文件不會顯示

  • May 7, 2018

我正在嘗試將文件從本地機器傳輸到遠端機器。

當我scp不使用-v選項時,它只給出以下輸出:

.--. or '\033[0;1;33;93m.-\033[0;1;32;92m-.\033[0m'

當我嘗試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

在此處sshd_config查看文件。請注意,我可以進入遠端機器。也返回。ssh``ssh user@IP pwd``/home/user

$$ Q $$ scp成功傳輸文件,但它沒有顯示在遠端電腦上。這可能是什麼原因,我該如何解決?

確保您的 shell 中沒有將數據回顯到終端的啟動腳本。這可能在.bashrc.profile

當 scp 連接到遠端主機時,它希望看到 SSH 伺服器標頭,然後是打開的標準輸入流。

如果遠端主機上的 .profile 回顯任何輸出,則會導致 scp 靜默失敗。如果是這種情況,您可能需要刪除它或設置一個保護條件以確保在沒有控制 tty 設備的情況下不會列印任何內容。請參閱tty命令。

引用自:https://unix.stackexchange.com/questions/441061