[Question] How to ssh as app user?

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

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

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

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

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

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

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

Then on the new server

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

And restore the backup

yunohost backup restore backupfile

or via the webadmin

1 Like

thanks! I I didn’t quite understand everything you said, but in the end I just went ahead and chowned 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.

1 Like

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