# \[Question\] How to ssh as app user?

**URL:** https://forum.yunohost.org/t/question-how-to-ssh-as-app-user/31950
**Category:** Discuss
**Tags:** ssh, english
**Created:** [November 11, 2024, 8:05pm UTC](https://forum.yunohost.org/t/question-how-to-ssh-as-app-user/31950 "2024-11-11T20:05:06Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dankerthrone](https://forum.yunohost.org/user_avatar/forum.yunohost.org/dankerthrone/32/10196_2.png) [@dankerthrone](https://forum.yunohost.org/u/dankerthrone)
#### Post date: [November 11, 2024, 8:05pm UTC](https://forum.yunohost.org/t/question-how-to-ssh-as-app-user/31950/1 "2024-11-11T20:05:06Z")

</div>

**What type of hardware are you using** : VPS bought online  
**What YunoHost version are you running** : 12.0.6  
**How are you able to access your server** : The webadmin  
SSH  
**Are you in a special context or did you perform specific tweaking on your YunoHost instance ?** : nope

### Describe your issue

I want to directly rsync files and folders from my old yunohost server/instance to my new one. I want to rsync directly into the new nextcloud data directory at /home/yunohost.app/nextcloud/data/$user because of space considerations and also to keep attributes such as date created / modified etc.

I’ve learned that the way to do this is **not** to rsync-ssh from my old machine into my new one as root, but rather as the directory’s owner: the user _nextcloud_. This user on my new machine was created by yunohost. I think that’s a smart way of handling these things, but now I’m stumped - how do I login as my nextcloud user?

### Share relevant logs or error messages

authentication failure

---

<div class="post-metadata">

### Author: ![rodinux](https://forum.yunohost.org/user_avatar/forum.yunohost.org/rodinux/32/7029_2.png) [@rodinux](https://forum.yunohost.org/u/rodinux)
#### Post date: [November 12, 2024, 1:28am UTC](https://forum.yunohost.org/t/question-how-to-ssh-as-app-user/31950/2 "2024-11-12T01:28:05Z")

</div>

I think the user nextcloud could not have ssh rigths… The user app is just a user shell, he have no `home/$app` directory , no PATH, no `.ssh` file.

So I think you will need use your own user (root also can’t use ssh or only locally) to rsync files, then using root to change the owner of the directory `chown -R nextcloud: my_rsync_directory` and rsync the files in this folder inside the folder `/home/yunohost.app/nextcloud/data` like this: `rsync -av /home/my_user/my_rsync_directory/ /home/yunohost.app/nextcloud/data`

The problem is that a lot of things are edited in the database. If you are migrating a nextcloud, you need migrate the database ! and also if you want keep the authentification LDAP is a little complex.  
Here there is a how-to (in french) [Migrate Nextcloud / Migration Nextcloud](https://forum.yunohost.org/t/migrate-nextcloud-migration-nextcloud/3647)

Perhaps a better solution is to sync all files with a nextcloud client and then sync them again in the new nextcloud, or a very nice application to do the migration is OwnershipTransfer : [A new application for Framaspace: OwnershipTransfer – Framablog](https://framablog.org/2024/09/10/a-new-application-for-framaspace-ownershiptransfer/)

For info, you can open a shell as the user app, but is only to use `php occ` commands, for example

```auto
yunohost app shell nextcloud
php occ files:scan --all

```

Anyway, if the old server is also a Yunohost, why not use a backup ? Create a backup on the old server

```auto
yunohost backup create --apps nextcloud

```

Then download the backup in the webadmin. Try also extract locally in the `backupfile.tar` the file `backupfile.info.json`

transfer the backup on the new server

```auto
scp backupfile.tar my_user@domain.tld:~/
scp backupfile.info.json my_user@domain.tld:~/

```

Then on the new server

```auto
sudo -i 
chown root: /home/my_user/backupfile.*
mv /home/my_user/backupfile.* /home/yunohost.backup/archives/

```

And restore the backup

```auto
yunohost backup restore backupfile

```

or via the webadmin

---

<div class="post-metadata">

### Author: ![dankerthrone](https://forum.yunohost.org/user_avatar/forum.yunohost.org/dankerthrone/32/10196_2.png) [@dankerthrone](https://forum.yunohost.org/u/dankerthrone)
#### Post date: [November 15, 2024, 4:19pm UTC](https://forum.yunohost.org/t/question-how-to-ssh-as-app-user/31950/3 "2024-11-15T16:19:38Z")

</div>

thanks! I I didn’t quite understand everything you said, but in the end I just went ahead and `chown`ed the nextcloud data dir on the new machine to my default user, e.g. “Alex”.

I then ssh’ed into the old machine and rsynced all it’s nextcloud-data to the new machine, rsyncing via ssh as “Alex”. Once all the contents had been transferred, I logged into the new machine as Alex once again and did `chown -r` to its original user “nextcloud” again. Worked perfectly.

---

<div class="post-metadata">

### Author: ![system](https://forum.yunohost.org/uploads/default/original/2X/f/f59fe8e3ee6b100b4f574d30d6e30479c68b89f0.png) [@system](https://forum.yunohost.org/u/system)
#### Post date: [December 15, 2024, 4:19pm UTC](https://forum.yunohost.org/t/question-how-to-ssh-as-app-user/31950/4 "2024-12-15T16:19:47Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
