unison文件同步软件安装配置教程.docx
- 文档编号:14528280
- 上传时间:2023-06-24
- 格式:DOCX
- 页数:13
- 大小:839.68KB
unison文件同步软件安装配置教程.docx
《unison文件同步软件安装配置教程.docx》由会员分享,可在线阅读,更多相关《unison文件同步软件安装配置教程.docx(13页珍藏版)》请在冰点文库上搜索。
unison文件同步软件安装配置教程
Unison文件同步软件安装配置教程
Unisoncansynchronizefilesanddirectoriesonasinglemachine,orbetweentwomachinesonanetwork.(Thesameprogramrunsonbothmachines;theonlydifferenceiswhichoneisresponsiblefordisplayingtheuserinterface.)Ifyou'reonlyinterestedinasingle-machinesetup,thenlet'scallthatmachinetheCLIENT.Ifyou'resynchronizingtwomachines,let'scallthemCLIENTandSERVER.
Unison使用ssh方式在不同电脑之间同步文件,需要在服务器端创建ssh服务,在客户机端安装用于登录服务器的ssh客户端。
该教程使用cygwin创建ssh服务,使用其中的openssh组件作为客户端。
Unison本身不区分什么是服务器,什么是客户端,在它看来两个电脑是两个地位相同的副本,所以两个电脑可以互为服务器或客户端。
cygwin中有两个openssh是通过ssh方式登录远程系统所必须,在服务器端只用于配置ssh服务。
unison是文件双向同步工具,既可以同一个电脑中不同磁盘文件同步,亦可以在不同电脑中文件同步。
一、服务器端创建ssh服务(如果实验室服务器已配置完成,可忽略)
1、安装cygwin,其中必须安装的组件有openssh和unison。
(openssh只是登录ssh的客户工具,服务器端不安装openssh应该也可以,还是安上吧)
下图中Selectpackagestoinstall一定要确保openssh和unison选上了。
View切换到Full找到这两个组件,Current不是Skipped说明选上了。
之后安装完就行。
2、配置ssh服务,这个有点复杂,如果没看懂或失败了,XX“cygwin配置ssh服务”,多看几个博客。
2.1、添加环境变量
Path:
追加“安装目录\cygwin64\bin”,注意与之前的内容用英文分号隔开。
2.2、以管理员身份启动Cygwin64Terminal,键入ssh-host-config开始配置,参考下图。
***Info:
Noprivilegedaccountcouldbefound.
***Info:
Thisscriptplanstouse'cyg_server'.
***Info:
'cyg_server'willonlybeusedbyregisteredservices.
***Query:
Doyouwanttouseadifferentname?
(yes/no)no
***Query:
Createnewprivilegeduseraccount'cyg_server'?
(yes/no)yes
***Info:
Pleaseenterapasswordfornewusercyg_server.Pleasebesure
***Info:
thatthispasswordmatchesthepasswordrulesgivenonyoursystem.
***Info:
Enteringnopasswordwillexittheconfiguration.
***Query:
Pleaseenterthepassword:
输入密码
***Query:
Reenter:
再次输入密码
***Info:
User'cyg_server'hasbeencreatedwithpassword'cyg_server'.
***Info:
Ifyouchangethepassword,pleaserememberalsotochangethe
***Info:
passwordfortheinstalledserviceswhichuse(orwillsoonuse)
***Info:
the'cyg_server'account.
***Info:
Alsokeepinmindthattheuser'cyg_server'needsreadpermissions
***Info:
onallusers'relevantfilesfortheservicesrunningas'cyg_server'.
***Info:
Inparticular,forthesshdserverallusers'.ssh/authorized_keys
***Info:
filesmusthaveappropriatepermissionstoallowpublickey
***Info:
authentication.(Re-)runningssh-user-configforeachuserwillset
***Info:
thesepermissionscorrectly.[Similarrestrictionsapply,for
***Info:
instance,for.rhostsfilesifthershdserverisrunning,etc].
***Info:
Thesshdservicehasbeeninstalledunderthe'cyg_server'
***Info:
account.Tostarttheservicenow,call`netstartsshd'or
***Info:
`cygrunsrv-Ssshd'.Otherwise,itwillstartautomatically
***Info:
afterthenextreboot.
***Info:
Hostconfigurationfinished.Havefun!
服务创建完成后可在计算机—管理中看到。
2.3、使用客户端通过SSH登录远程Windows测试,格式:
ssh用户名@IP。
如果提示密码错误,可尝试在服务器端重置密码,命令:
passwd账户名
3、免密登录配置:
客户端cygwin中执行以下命令:
先看看安装路径\cygwin64\home\用户名\.ssh(如:
D:
\ProgramFiles\cygwin64\home\zhang\.ssh)这一系列路径是否都存在,如果不存在,需要在cygwin中创建缺失的文件夹,因为在Windows系统中新建文件夹、重命名为.ssh会提示键入文件名,需要通过Linux命令创建:
创建文件夹:
mkdir–r/home/你的计算机名/.ssh(添加参数-r可以创建多层)
进入文件件:
cd/home/你的计算机名/.ssh
$ssh-keygen
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/home/Administrator/.ssh/id_rsa):
直接回车
Createddirectory'/home/Administrator/.ssh'.
Enterpassphrase(emptyfornopassphrase):
不要密码,直接回车
Entersamepassphraseagain:
不要密码,直接回车
Youridentificationhasbeensavedin/home/Administrator/.ssh/id_rsa.
Yourpublickeyhasbeensavedin/home/Administrator/.ssh/id_rsa.pub.
Thekeyfingerprintis:
SHA256:
nLcKHtpT62vqKmMEj3DQAesn5OsmT5u4yLxMjRJ9e7IAdministrator@172-22-1-39
Thekey'srandomartimageis:
+---[RSA2048]----+
|.o..|
|...|
|.o|
|*....|
|oO...S.|
|..O.....|
|.=..o+...|
|X++oB.oo.|
|*X=oEo==+.|
+----[SHA256]-----+
catid_rsa.pub>>authorized_keys
到安装路径\cygwin64\home\用户名\.ssh找图示两个文件,两份文件内容相同,将文件复制一份到服务器端,将文件的内容追加到服务器端这两个文件中,OK!
4、如果服务器端需要备份功能,添加环境变量:
UNISONBACKUPDIR:
指向备份文件夹路径,不能是要同步的目录及其子目录。
二、客服端配置
1、同样安装cygwin,必须安装的组件有openssh和unison,安装完成后配置环境变量:
Path:
追加“安装目录\cygwin64\bin”,注意与之前的内容用英文分号隔开。
UNISON:
指向unison家目录,默认存放配置文件、日志文件等。
如:
D:
\ProgramFiles\Unison-2.48.4\unisonhome
UNISONBACKUPDIR:
指向备份文件夹路径,不能是要同步的目录及其子目录。
建议客户端不要添加这个环境变量,可以在每一个配置文件中单独指定备份位置。
2、远程连接配置文件编写,以同步ECAD为例,在安装目录\Unison-2.48.4\unisonhome下新建.prf文件,用文本编辑器编辑,配置文件写法参考如下,该文件中参数含义参考注释,或官方帮助文档。
#Unisonpreferences
label=本地E:
\MCAD_ECAD与服务器E:
\ECAD同步
root=E:
\MCAD_ECAD
root=ssh:
//thermech@192.169.80.1//cygdrive/e/ECAD
#Someregexpsspecifyingnamesandpathstoignore
ignore=Nametemp.*
ignore=Name*.tmp
ignore=Name*.temp
ignore=Name同步记录日志.txt
ignore=Path*backup*
ignore=Name*.emn
ignore=Name*.emp
ignore=Name*.log.*
ignore=Name*.map
ignore=Name*.bak
ignore=Name*_hint*
ignore=Name*.txt
#本地不删除
nodeletion=E:
\MCAD_ECAD
#同步修改时间、用户、组、权限等文件属性(Windows系统下未看出区别)
owner=true
times=true
watch=true
perms=-1
group=true
#备份设置
backup=Name*
backuplocation=central
#useitasthenameofthedirectoryusedtostorebackupfiles
#环境变量中指出,不需定义
backupdir=F:
\UNISONBACKUPDIR\MCAD_ECAD
maxbackups=3
logfile=E:
\MCAD_ECAD\同步记录日志.txt
3、Unison使用:
运行unisonxxxGTK.exe出现三个窗口,最上层窗口用于管理、选择配置文件。
4、最后几点提示:
(1)如果打开后闪退,检查配置文件中是否存在尚未建立的路径
(2)每次同步都会分别在服务器和客户端产生两个归档文件,客户端在D:
\ProgramFiles\Unison-2.48.4\unisonhome路径中,服务器端在D:
\ProgramFiles\cygwin64\home\thermech\.unison中,如下图:
如果某个归档文件删除了,打开Unison会产生FetalError,按提示解决,删除另外一个归档文件,或使用-ignorearchives参数启动Unison,方法如下:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- unison 文件 同步 软件 安装 配置 教程