Commit 7ba680d3 authored by Yuanle Song's avatar Yuanle Song
Browse files

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.
parent b363509a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -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))
+1 −0
Original line number Diff line number Diff line
@@ -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
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
    <RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
    <RootNamespace>Mbackup</RootNamespace>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <Version>0.5.3.0</Version>
    <Version>0.6.0.0</Version>
  </PropertyGroup>

  <ItemGroup>
+31 −24
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@
            <Directory Id="MBACKUP_PROGRAM_FILES" Name="mbackup" />
        </Directory>
        <Directory Id="CommonAppDataFolder">
          <Directory Id="MBACKUP_DATA" Name="mbackup"/>
            <Directory Id="MBACKUP_DATA" Name="mbackup">
                <Directory Id="MBACKUP_SSH_DIR" Name=".ssh" />
            </Directory>
        </Directory>
        <Directory Id="DesktopFolder" Name="Desktop" />
        <Directory Id="ProgramMenuFolder">
@@ -68,6 +70,10 @@
        </Component>
    </DirectoryRef>

    <Component Id="mbackup_ssh_dir" Directory="MBACKUP_SSH_DIR" Guid="8FC95FD8-DFA3-45D0-9CF1-45F010FEA3E2">
        <CreateFolder />
    </Component>

    <DirectoryRef Id="DesktopFolder">
        <Component Id="MbackupDesktopShortcut" Guid="*">
            <Shortcut Id="DesktopMbackupExe"
@@ -152,6 +158,7 @@
        <ComponentRef Id="user_default_list.txt" />
        <ComponentRef Id="MbackupDesktopShortcut" />
        <ComponentRef Id="MbackupStartMenuShortcuts" />
        <ComponentRef Id="mbackup_ssh_dir" />
    </Feature>
  </Product>
</Wix>
+31 −10
Original line number Diff line number Diff line
@@ -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.