Skip to content

Commit

Permalink
ssh-rsa
Browse files Browse the repository at this point in the history
  • Loading branch information
LobbyLobster committed Mar 25, 2024
1 parent 94a1ca9 commit 13d889d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 9 additions & 5 deletions backup/rsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@ func SendRsync(srcPath, dstPath, db string, target config.Target) {
var stderr2 bytes.Buffer
var stdout bytes.Buffer
logger.Info("rsync transfer started.\n Source: " + srcPath + " - Destination: " + target.Host + ":" + dstPath)
dstPath = target.Path + "/" + nameWithPath(dstPath)
if target.Path != "" {
dstPath = target.Path + "/" + nameWithPath(dstPath)
} else {
dstPath = nameWithPath(dstPath)
}
fullPath := strings.Split(dstPath, "/")
newPath := "/"
for i := 0; i < len(fullPath)-1; i++ {
newPath := fullPath[0]
for i := 1; i < len(fullPath)-1; i++ {
newPath = newPath + "/" + fullPath[i]
}
cmdMkdir := exec.Command("ssh", target.Host, "mkdir -p "+newPath)
cmdMkdir := exec.Command("ssh", "-o", "HostKeyAlgorithms=+ssh-rsa", "-o", "PubKeyAcceptedKeyTypes=+ssh-rsa", target.Host, "mkdir -p "+newPath)
err := cmdMkdir.Run()
if err != nil {
cmdMkdir.Stderr = &stderr1
notify.SendAlarm("Couldn't create folder "+newPath+" to upload backups at"+target.Host+":"+dstPath+"\nError: "+err.Error()+" "+stderr1.String(), true)
logger.Error("Couldn't create folder " + newPath + " to upload backups at" + target.Host + ":" + dstPath + "\nError: " + err.Error() + " " + stderr1.String())
return
}
cmdRsync := exec.Command("/usr/bin/rsync", target.Flags, srcPath, target.User+"@"+target.Host+":"+dstPath)
cmdRsync := exec.Command("/usr/bin/rsync", target.Flags, "-e", "ssh -o HostKeyAlgorithms=+ssh-rsa -o PubKeyAcceptedKeyTypes=+ssh-rsa", srcPath, target.User+"@"+target.Host+":"+dstPath)
cmdRsync.Stderr = &stderr2
cmdRsync.Stdout = &stdout
err = cmdRsync.Run()
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/kr/fs v0.1.0 // indirect
Expand Down

0 comments on commit 13d889d

Please sign in to comment.