# Backing up MIAB via SFTP

**URL:** <https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866>\
**Category:** Maintenance\
**Created:** [January 26, 2017, 7:51pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866 "2017-01-26T19:51:25Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattF](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@MattF](https://discourse.mailinabox.email/u/MattF)\
**Post date:** [January 26, 2017, 7:51pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/1 "2017-01-26T19:51:25Z")

</div>

Sorry my linux skills are very limited i’m running into an issue where i use WinSCP to manually backup files and auto FTP Manager to automate the backup of the files but everytime i try to backup the files i’m getting file permission error and can’t download the file/folder. i’m using the standard setup of /home/user-data/backup/encrypted to backup

---

<div class="post-metadata">

**Author:** ![cromulus](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/cromulus/32/495_2.png) [@cromulus](https://discourse.mailinabox.email/u/cromulus)\
**Post date:** [January 26, 2017, 11:38pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/2 "2017-01-26T23:38:39Z")

</div>

What is the user you are connecting to MIAB with?

Should probably be root.

---

<div class="post-metadata">

**Author:** ![MattF](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@MattF](https://discourse.mailinabox.email/u/MattF)\
**Post date:** [January 27, 2017, 1:43am UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/3 "2017-01-27T01:43:47Z")

</div>

I’m using the default login i created at setup, but not using the username root. i though its good to leave that account disabled by default? should i re-enable it?

---

<div class="post-metadata">

**Author:** ![Woody](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/w/ac91a4/32.png) [@Woody](https://discourse.mailinabox.email/u/Woody)\
**Post date:** [January 27, 2017, 8:36am UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/4 "2017-01-27T08:36:47Z")

</div>

I think that you cannot login using root on a Ubuntu based system. That means that you have to make WinSCP do a sudo. There is some info on this here:

[https://winscp.net/eng/docs/faq\_su#sudo](https://winscp.net/eng/docs/faq_su#sudo)

I toyed with this earlier this week but could not make it work right away. Not by re-owning the backup files to my default user, and not by making sudo work with WinSCP. Then I managed to make backup via rsync to my NAS working, so I did not pursue this any longer. But I still would be interested in a way to WinSCP to MAIB, for one of these days these backup files might need to be transferred back to the mailserver 🙂

Kind regards,

Paul

---

<div class="post-metadata">

**Author:** ![cromulus](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/cromulus/32/495_2.png) [@cromulus](https://discourse.mailinabox.email/u/cromulus)\
**Post date:** [January 27, 2017, 6:04pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/5 "2017-01-27T18:04:40Z")

</div>

@Woody and @MattF  
Depending on the flavor of Ubuntu (Digital Ocean, Linode, Amazon, etc.) the default user is either “ubuntu” or “root”

MIAB doesn’t create another user and so the user you used to log in to the machine to initially install MIAB is the only user you will ever be able to log into the machine with unless you explicitly add another linux user.

The backup directory on a fresh MIAB installation is owned by root. How to configure WinSCP is beyond me though.

---

<div class="post-metadata">

**Author:** ![Woody](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/w/ac91a4/32.png) [@Woody](https://discourse.mailinabox.email/u/Woody)\
**Post date:** [January 28, 2017, 10:40am UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/6 "2017-01-28T10:40:55Z")

</div>

I use my own hardware on which I installed Ubuntu from scratch. You then end up with a non-root user that has the rights to sudo to root with the same password as that user. I could not figure out how to get WinSCP (or Syncovery, the automated backup program I use for the rest of my data) to log in as the non-root user and then perform a sudo to get access to the backup files.

Taking into account that these files are encrypted they probably could safely be put into a less closed-off directory to make it simpler to get them off the server using tools like WinSCP. But as stated, I solved the problem another way 🙂

---

<div class="post-metadata">

**Author:** ![CorneliusLentulus](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/c/8e8cbc/32.png) [@CorneliusLentulus](https://discourse.mailinabox.email/u/CorneliusLentulus)\
**Post date:** [February 2, 2018, 3:49pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/7 "2018-02-02T15:49:38Z")

</div>

This is a legitimate question imho. Using SFTP/WinSCP does not work to download the backup folder due to permission issues. Although it is mentioned in the [maintenance description](https://mailinabox.email/maintenance.html): “Copy that file onto your new box. Any SFTP program like FileZilla can help you with that. (SFTP is like SSH, so you will use the same login credentials as you use with SSH.)”.  
@JoshData is changing the permission of the folder an option? … guess not due to security reasons.

---

<div class="post-metadata">

**Author:** ![murgero](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/murgero/32/750_2.png) [@murgero](https://discourse.mailinabox.email/u/murgero)\
**Post date:** [February 2, 2018, 3:52pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/8 "2018-02-02T15:52:48Z")

</div>

SFTP _should_ allow you to sudo to root and then copy folder…

---

<div class="post-metadata">

**Author:** ![CorneliusLentulus](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/c/8e8cbc/32.png) [@CorneliusLentulus](https://discourse.mailinabox.email/u/CorneliusLentulus)\
**Post date:** [February 2, 2018, 4:00pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/9 "2018-02-02T16:00:00Z")

</div>

while it _should_ be possible to start SFTP with sudo, it is hard to find a GUI client that supports that. 😐

---

<div class="post-metadata">

**Author:** ![murgero](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/murgero/32/750_2.png) [@murgero](https://discourse.mailinabox.email/u/murgero)\
**Post date:** [February 2, 2018, 9:22pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/10 "2018-02-02T21:22:44Z")

</div>

This looks promising for your needs: [https://winscp.net/eng/docs/faq\_su](https://winscp.net/eng/docs/faq_su)

---

<div class="post-metadata">

**Author:** ![cwilkins](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cwilkins](https://discourse.mailinabox.email/u/cwilkins)\
**Post date:** [February 2, 2018, 10:13pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/11 "2018-02-02T22:13:11Z")

</div>

Another option is to enable root, which can be done easily in Ubuntu 14.04, however make sure you create a secure password. You will also have to give root the ability to SSH. Let me know if you would like to know how to do that.

---

<div class="post-metadata">

**Author:** ![murgero](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/murgero/32/750_2.png) [@murgero](https://discourse.mailinabox.email/u/murgero)\
**Post date:** [February 3, 2018, 9:16pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/12 "2018-02-03T21:16:55Z")

</div>

Use pubkey auth, not a password with root.

---

<div class="post-metadata">

**Author:** ![cwilkins](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/c/e9a140/32.png) [@cwilkins](https://discourse.mailinabox.email/u/cwilkins)\
**Post date:** [February 3, 2018, 10:43pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/13 "2018-02-03T22:43:08Z")

</div>

Yes, that is a much better way to use root.

---

<div class="post-metadata">

**Author:** ![murgero](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/murgero/32/750_2.png) [@murgero](https://discourse.mailinabox.email/u/murgero)\
**Post date:** [February 8, 2018, 3:37pm UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/15 "2018-02-08T15:37:04Z")

</div>

WinSCP works on linux, but scp is also a linux and Mac tool.

---

<div class="post-metadata">

**Author:** ![ray](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/r/e9a140/32.png) [@ray](https://discourse.mailinabox.email/u/ray)\
**Post date:** [March 17, 2019, 11:06am UTC](https://discourse.mailinabox.email/t/backing-up-miab-via-sftp/1866/16 "2019-03-17T11:06:07Z")

</div>

An old thread but came up when I did a search re backups and sftp and haven’t seen much else around so will post my solution here, maybe helpful for others.

I recently did a clean MIAB install on the latest Ubuntu 18.04. I’m looking to pull backups off the server rather than push them from the server to another location.

Having poked around a bit I found the files in _/home/user-data/backup/encrypted_ around owned by _user-data_ and belong to the _root_ group. Not keen on opening root or changing the permissions of those files so I had a look at the _user-data_ user and it was simple enough to add an `authorized_keys` entry and remotely login via the key. Then I switched my backuppc rsync to use _user-data_ rather than _root_ and job done.

In a simple summary on the client you need to generate a key, if don’t already have one:

```auto
ssh-keygen

```

Copy the generated **_id\_rsa.pub_** key to the MIAB server using any method you like. The contents of the copied file need to end up in:

`/home/user-data/.ssh/authorized_keys`

If this is a new install you’ll likely find the last directory and file don’t exist so you can create the directory and rename your file, otherwise you can append the contents of your new key to the existing file.

Plenty of detailed instructions out there [like this one](https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-on-ubuntu-1604) cover the key setup and transfer.

I locked mine down to IP address as well using the `from="x.x.x.x"` format but again better write ups of the `authorized_keys` features for restrictions already exist [such as these](https://debian-administration.org/article/685/Restricting_SSH_logins_to_particular_IP_addresses)
