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

原文地址:https://www.cnblogs.com/gcgc/p/5806330.html