eworm-de / routeros-scripts

a collection of scripts for MikroTik RouterOS
GNU General Public License v3.0
1.27k stars 285 forks source link

Backup Upload via SFTP not working #77

Closed rpchan44 closed 3 weeks ago

rpchan44 commented 3 weeks ago

global-config-overlay

:global BackupRandomDelay "30"; :global BackupUploadUrl "sftp://192.168.99.4/"; :global BackupUploadUser "z1"; :global BackupUploadPass "p@ssw0rd23";

Using normal SFTP i was able to upload file using "z1" as user

This is the error has been log in MT during backup script execution

Upload to 192.168.99.4 FAILED: closing connection: \<permission denied> 192.168.99.4:22 (6) (6)

on 192.168.99.4 /etc/ssh/sshd_config I append the following section

Match User z1 AuthenticationMethods password

This was tested on v7.15.2 thanks a lot much appreciate it!!

failed

eworm-de commented 3 weeks ago

Hmm, not absolutely sure, but "permission denied" sounds like file permission... So I guess the authentication succeeded, but file could not be written. Possibly you missed the remote path or the destination folder is not writable? Any logs from the server that indicate what the issue could be?

rpchan44 commented 3 weeks ago

Thanks for your prompt reply, I was confused too both scp and sftp is working properly afaic

success sftp winbox

eworm-de commented 3 weeks ago

Not sure if implementations differ in handling of default directory. You could try:

:global BackupUploadUrl "sftp://192.168.99.4/home/z1/";

Does that work?

rpchan44 commented 3 weeks ago

Yes that fixed it!!!! the sftp client implementation from mikrotik is flawed? anyway thanks a lot for your great effort!! please close this now

eworm-de commented 3 weeks ago

No, it's ok - it just expects the complete path.

Have a look at your screenshots... For scp your added ~ which is equivalent to /home/z1/ here. The interactive sftp just opens at the home directory automatically.