Permission denied when installing plugin

I have my own plugin that I want to install into a new ubuntu system. I have installed everything using standard settings.

When I run bin/kibana-plugin install file://<zip-file-path> I get the error:

Plugin installation was unsuccessful due to error "EACCES: permission denied, open '/usr/share/kibana/plugins/.plugin.installing/package.json'"

I have really tried to change permissions and everything, but nothing seems to be working. The permissions for my folder /usr/share/kibana folder is drwxrwxr-x and chown says: user:kibana.

When I run the kibana-plugin install command, which user/group are the commands performed using?

I rather not leave my elastic stack open by setting the kibana folder as writable for all users and groups, but am not sure what else I can do at this moment.

You can try doing only the install as root and that way you won't have to make the kibana folder writable.

I could, but since I then have to add also the flag --allow-root this cannot be the intended way. There must surely be some other issues related to this.

Maybe a more general question to help could be what user is the kibana-plugin run as? My user or the kibana user that kibana created for me?

How will I be sure that kibana has the right access to load and use my installed plugin afterwards?

Is there no other suggestions why I am getting this error?

Maybe a better idea to start would be what should be my permissions and owner in unix for my /usr/share/kibana folder and all its subfolders? I have setup my kibana and es as a systemctl service. Might be that I maybe wrongly changed some permissions?

This is the current permission for my /usr/share/kibana/ folder:

drwxrwsr-x  12 kibana kibana  4096 Nov 29 15:12 kibana

I had this problem. I found that if you ziped up the plugin in windows it would cause the error. But when I zipped up the plugin in Linux and then installed it worked perfect. It was very weird but it worked for me.