天天看點

SCP的兩個問題解決

參考文章:

https://www.cnblogs.com/jockechen/articles/10407093.html

https://www.cnblogs.com/huanghongbo/p/6254400.html

https://blog.csdn.net/dafei4/article/details/79494324

scp使用

從linux系統複制檔案到windows系統:

scp <linux_path> [email protected]<windows_ip>:<windows_path>
           

在linux環境下,将windows下的檔案複制到linux系統中:

scp [email protected]<windows_ip>:<windows_path> <linux_path>
           

windows的路徑用'/'作為分隔符。

請注意:因為windows系統本身不支援ssh協定,是以,要想上面的指令成功執行,必須在windows用戶端安裝ssh for windows的用戶端軟體,比如winsshd,使windows系統支援ssh協定才行。

以上的指令我沒試過,以前好像是用putty直接完成的,也不需要輸入指令,可以直接拖拽。

linux 到 linux :

scp <src_path> <dest_username>@<dest_ip>:<dest_path>
           

scp source  [email protected]_ip:destination_filepath   #注意#目的地的url路徑中不要漏掉冒号。

報錯一:

The authenticity of host '114.212.xx.xx (114.212.xx.xx)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? 
           

解決方法:

不要選擇yes或no,直接ctrl+c。然後輸入下面指令

ssh  -o StrictHostKeyChecking=no  114.212.xx.xx
           

輸入密碼。接着exit登出,系統輸出以下兩行:

logout
Connection to 114.212.xx.xx closed.
           

回到了原來的伺服器。

接着重新使用scp指令就不會報錯了。

報錯二:

.: not a regular file
           

表明目前目錄不是一個檔案,因為是個檔案夾。如果傳送單個檔案是不會出錯的。

解決方法:

scp -r <src_path> <dest_username>@<dest_ip>:<dest_path>
           

加個-r參數就好了。

繼續閱讀