本文主要记录工作中解决Ubuntu16(desktop版)与windows10之间进行文件传输的几种方法。采用的环境为:windows10、服务器Ubuntu16(desktop版, 部署在vmware workstation上)。此外,以下方法同样适用于 win7 和 Ubuntu14.04 。
实现Ubuntu16/14(desktop版,64位)与win10/7 之间进行文件的方法有:
1、安装VMware Tools工具。
2、利用ssh工具。
3、利用文件共享的方式。
以下就3种方式分别介绍。
1、安装VMware Tools工具
有的vmware workstation 安装后已经带有VMware Tools工具,而我的并没有。解决方案参考如下:
http://jingyan.baidu.com/article/3c48dd348c4504e10ae35810.html
注意是选择文章中的linux.iso,感谢网络上的共享者。
安装VMware Tools工具后,选择win10系统上任意文件,复制后到Ubuntu16中粘贴即可。
2、利用ssh工具
利用ssh工具连接Ubuntu系统进行文件传输,是多数人的首选。
Ubuntu缺省安装了openssh-client(可用命令:dpkg -s openssh-client 查看),但是没有安装openssh-server,所以利用win10上的SSH Secure File Transfer 连接Ubuntu16,弹出:
The host "192.1xx.2xx.1xx" is unreachable. The host may be down,or there may be a problem with the network connection.Sometimes such problems can also be caused by a misconfiured firewall"
给出的提示是:无法连接,可能是网络或防火墙配置的问题。
1)排除是否是网络的问题。打开windows上的cmd,ping 一下Ubuntu服务器,显示正常,排除是网络的问题。
2)排除是否是防火墙的问题。打开Ubuntu上的terminal,输入: sudo ufw status,提示 status:inactive 。防火墙是关闭的,排除防火墙的问题。
3)查询是否安装openssh-server,打开Ubuntu上的terminal,输入:dpkg -s openssh-server,显示未安装。ok,连接不上的原因找到!
-----安装openssh-server,在Ubuntu上的terminal中输入:sudo apt-get install openssh-server 安装openssh-server(中间提示是否继续,输入 y 按enter键确定)。
-----安装完成后,输入:ps -e |grep sshd ,查询发现有该进程,安装成功。
-----继续点击win10上的SSH Secure File Transfer 连接Ubuntu,又弹出错误:Server responded Algorithm negotiation failed......",晕,这是要闹那样!网上搜一下,给出的解决方案有几类,不过针对本文中的环境,实际可行的解决方案为:
在 /etc/ssh/sshd_config 配置文件中添加:
Ciphers aes128-cbc,aes192-cbc,aes256-cbc,aes128-ctr,aes192-ctr,aes256-ctr,3des-cbc,arcfour128,arcfour256,arcfour,blowfish-cbc,cast128-cbc
MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
KexAlgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2- nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group1-sha1,curve25519-sha256@libssh.org
然后重启ssh服务:sudo service ssh restart。
---- 再次用 SSH Secure File Transfer 连接Ubuntu,ok成功了。
---- 小结:sshd_config配置文件中敲那么一段,有点太令人抓狂,实际中我并没有那么操作,而是安装VMware Tools工具后,复制进来完成的。
3、利用文件共享的方式
---- 在Ubuntu上安装cifs-utils: sudo yum -y install cifs-utils
---- 在win10的f盘下建一个share文件夹,右键-属性-共享,选择everyone
---- 将要传输的文件拷贝进share文件夹
---- 在win10的cmd中,输入ipconfig ,查看win10的ip
---- 在Ubuntu的terminal中输入:sudo mount -t cifs -o username=myname,password=pwd /ip/share /home
其中 : username=myname,password=pwd 为windows系统的用户和密码,ip为windows的IP地址, share为 windows下建立的共享文件夹,注意这里不用加上f:/
/home为Ubuntu系统中要拷入的文件夹。