Linux和windows之間通過scp復制文件


Windows是不支持ssh協議的 需要安裝WinSSHD 

安裝以及設置過程如下:

BvSshServer(原名winsshd)官方下載頁在這里:https://www.bitvise.com/download-area

下載完成BvSshServer-Inst.exe

接下來我們安裝

首先會跳出一個黑框和一個窗口,黑框在安裝過程中不用管它。

點擊“I agree to accept all the terms of this License Agreement”(同意條款)

點擊Install安裝

接下來會跳出版本選擇窗口,標准版(Standard edition)有30天試用期,個人版(Person edition)有功能限制,鑒於目前測試暫時用不到標准版功能,這里選個人版。

稍后我們會在黑框看到安裝進度,安裝完成后會有提示,在提示框點擊確定

 

在彈出的控制面板中選擇“open easy settings”接下來我們配置一個虛擬賬戶

在服務器設定的防火牆設置中,選擇對所有計算機開放端口(默認只對子網開放端口)

切換到windows賬戶標簽卡中,取消選中(不允許使用windows賬戶登錄)

切換到虛擬賬戶選項卡,添加一個用戶名和密碼均為admin的賬戶。

這里最好配置成免密碼登錄:點擊public keys 導入公鑰文件 id_rsa.pub

回到控制面板,選中啟動服務

啟動完之后我們可以用netstat -a命令看22端口是否打開

上面服務端配置完畢。

如果出現下面提示:

root@Docker-Master:/# ssh guchen@10.3.2.35
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the DSA key sent by the remote host is
SHA256:ahuAO/5uvmSOF1eSUj6p8a3P2q6SvP0/QpNrl0F+Fjg.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending RSA key in /root/.ssh/known_hosts:3
remove with:
ssh-keygen -f "/root/.ssh/known_hosts" -R 10.3.2.35
DSA host key for 10.3.2.35 has changed and you have requested strict checking.
Host key verification failed.

經過google,出現這個問題的原因是,第一次使用SSH連接時,會生成一個認證,儲存在客戶端的known_hosts中.

可使用以下指令查看:

ssh-keygen -l -f ~/.ssh/known_hosts

由於服務器重新安裝系統了,所以會出現以上錯誤。

解決辦法

ssh-keygen -R 服務器端的ip地址

會出現以下提示:

Host 10.3.2.35 found: line 1 type RSA

/用戶home目錄/.ssh/known_hosts updated.
Original contents retained as /用戶home目錄/.ssh/known_hosts.old

重新連線,出現以下提示:

The authenticity of host '192.168.3.10 (192.168.3.10)' can't be established.
RSA key fingerprint is da:f7:3e:ba:f7:00:e6:44:76:f2:58:6e:48:**.
Are you sure you want to continue connecting (yes/no)?

輸入yes確認即可連線成功.

 

配置完成后就可以Linux和Windows之間復制文件了

Linux到Windows

root@Docker-Master:/# scp initrd.img guchen@10.3.2.35:/f:/test

windows到Linux

root@Docker-Master:/# scp guchen@10.3.2.35:/f:/test/test.txt ./home


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM