File push uid and how to set the owner of the file

lxc file push has the option --uid. That is a number.

Using cloud init, I can create an user, let’s call it foo.

I would love to be able to do

lxc file push a-file.txt my-instance/path/ --owner=foo

But lxc options are limited to pass the user id, so supposing the user id of foo is 33, the previous imaginary command would actually be:

lxc file push a-file.txt my-instance/path/ --uid 33

So:

Is there any plan to extend the push command to allow us to define the owner by name and not by id?

For now, what I’ll do is a 2 step process

#!/bin/bash
lxc exec my-instance -- id foo --user | \
lxc file push a-file.txt my-instance/path/ --uid `cat`

How else would you do that?

Hi @Jesus_Gomez,
One step process may be,

lxc file push a-file.txt my-instance/path/ --uid `lxc exec myinstance -- id foo --user`

Regards.

Does it have to be done later? Could you instead use write_files in cloud-init?

Right!

It depend on the context.

So yes, write_files could be used if no need to pass it later.

If not, well, file push is one way. rsync, scp, etc… others.

One reason why one would like to pass it later is security. Maybe the file content should not be in the user-data.