From 7ba680d3ba794315f6f2c5493bfeba3d76774667 Mon Sep 17 00:00:00 2001 From: Yuanle Song Date: Sat, 23 Nov 2019 01:00:16 +0800 Subject: [PATCH] v0.6.0.0 reset default .ssh config dir location use a global shared .ssh dir for all users. do not use current user's ~/.ssh This is to ease mbackup configuration and make sure if it runs for one user, it runs for other users too. --- Program.fs | 6 +++--- README.md | 1 + mbackup.fsproj | 2 +- mbackup.wxs | 55 ++++++++++++++++++++++++++++---------------------- operational | 41 ++++++++++++++++++++++++++++--------- 5 files changed, 67 insertions(+), 38 deletions(-) diff --git a/Program.fs b/Program.fs index 34425b8..d0a1b36 100644 --- a/Program.fs +++ b/Program.fs @@ -206,9 +206,9 @@ exception PrivateKeyNotFoundException of string let addOptionsForRemoteBackup (rc: MbackupRuntimeConfig) (rsyncCmd: string list) = let options = rc.Options let sshExeFile = mbackupProgramDir + "rsync-w64/usr/bin/ssh.exe" - let sshConfigFile = userHome + ".ssh/config" - let sshKnownHostsFile = userHome + ".ssh/known_hosts" - let sshPrivateKeyFile = options.GetResult(Ssh_Key, rc.Config.GetStrDefault "ssh-key" (userHome + ".ssh/id_rsa")) |> toMingwPath + let sshConfigFile = userConfigDir + ".ssh/config" + let sshKnownHostsFile = userConfigDir + ".ssh/known_hosts" + let sshPrivateKeyFile = options.GetResult(Ssh_Key, rc.Config.GetStrDefault "ssh-key" (userConfigDir + ".ssh/id_rsa")) |> toMingwPath let sshPrivateKeyFileWin = toWinPath sshPrivateKeyFile if not (File.Exists(sshPrivateKeyFileWin)) then raise (PrivateKeyNotFoundException("ssh private key doesn't exist: " + sshPrivateKeyFileWin)) diff --git a/README.md b/README.md index 9ada04f..7a29490 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Replace D:\backup with the dir you want to save backup files to. To backup to remote ssh node, add config target=user@somehost.example.com:/path/to/dir + # default ssh-key path is %programdata%\mbackup\.ssh\id_rsa ssh-key=D:\path\to\id_rsa Replace ssh-key path with your ssh private key. Since mbackup is designed to diff --git a/mbackup.fsproj b/mbackup.fsproj index 38ffea7..c06723e 100644 --- a/mbackup.fsproj +++ b/mbackup.fsproj @@ -23,7 +23,7 @@ win10-x64 Mbackup true - 0.5.3.0 + 0.6.0.0 diff --git a/mbackup.wxs b/mbackup.wxs index cb51c89..c624008 100644 --- a/mbackup.wxs +++ b/mbackup.wxs @@ -24,14 +24,16 @@ - + - + + + - + @@ -45,29 +47,33 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/operational b/operational index 4706149..a2323db 100644 --- a/operational +++ b/operational @@ -143,6 +143,9 @@ C:\ProgramData\mbackup\local-exclude.txt - optional user configs C:\ProgramData\mbackup\local-list.txt C:\ProgramData\mbackup\local-exclude.txt + C:\ProgramData\mbackup\.ssh\id_rsa + C:\ProgramData\mbackup\.ssh\config + C:\ProgramData\mbackup\.ssh\known_hosts - auto create these two files if they do not exist on target node. never overwrite existing file. @@ -244,16 +247,6 @@ vscode should at least always indent using space for F#. ** ** 2019-11-19 allow local Users group to have full access to local list and local exclude file. by default, only admin can modify them, Users can only read/execute them. -** 2019-11-19 drop the mbackup-logon task. -it never runs. - -- problem - - why it never runs? - if it runs fine, I would rather keep this task. - -** 2019-11-18 get a simple web page up to host the msi file. -see URL in README.md -serve msi from apt.emacsos.com CDN. ** 2019-11-18 add dockerfile to create rsync mingw64 distribution, then update Makefile and wix xml files to use that. @@ -266,6 +259,34 @@ Are there any code change required? ** 2019-11-18 add log rotate for %localappdata%\mbackup\mbackup.log * done :entry: +** 2019-11-23 update ssh config file path. +don't use ~/.ssh/ +use %programdata%/mbackup/.ssh instead. + +because mbackup is run for current user when run in Task Scheduler and in cmd.exe. +the ssh key and known hosts file should be shared. + +use current user's home dir would require copy the files to everywhere and recreate known +hosts file every time. Share a single .ssh config dir makes more sense. + +- problems + - can I create an empty .ssh dir when msi installer runs? + if not easy, I will just add an empty ssh config file. + +** 2019-11-18 get a simple web page up to host the msi file. +see URL in README.md +serve msi from apt.emacsos.com CDN. + +it's published in my blog. + +** 2019-11-19 drop the mbackup-logon task. +it never runs. + +- problem + - why it never runs? + if it runs fine, I would rather keep this task. + I have seen it run successfully. just not every time when I logon. + I will keep the task. ** 2019-11-18 apply gpl. rsync is gplv3. I will apply gplv3. ** 2019-11-12 make code work in a specific dir. then create an installer. -- GitLab