# MutliTenancy for Cockpit

**URL:** <https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347>\
**Category:** Feature Request\
**Created:** [April 12, 2020, 8:54pm UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347 "2020-04-12T20:54:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![terencejackson8000](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/terencejackson8000/32/641_2.png) [@terencejackson8000](https://discourse.getcockpit.com/u/terencejackson8000)\
**Post date:** [April 12, 2020, 8:54pm UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/1 "2020-04-12T20:54:43Z")

</div>

Dear all,

it would be great if there could be multiple tenants on one Cockpit installation.  
Basically I mean that the data is seperated based on the login and the assigned tenant to the logged in user. This should also apply to the API of course.

If this is already possible, please let me know how I can achieve this.

---

<div class="post-metadata">

**Author:** ![bet0x](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bet0x](https://discourse.getcockpit.com/u/bet0x)\
**Post date:** [May 3, 2020, 11:15am UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/2 "2020-05-03T11:15:13Z")

</div>

+1 on this suggestion. I created a new user and i was expecting multiple tenants to be supported as in other platforms but sadly is not.

---

<div class="post-metadata">

**Author:** ![bet0x](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bet0x](https://discourse.getcockpit.com/u/bet0x)\
**Post date:** [May 4, 2020, 12:57am UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/3 "2020-05-04T00:57:46Z")

</div>

> \<?php $app-\>on('cockpit.bootstrap', function() { echo print\_r($this-\>config, true); });

I made a folder inside addons, created a bootstrap.php and i got access to the config variables. I think it can be easy to override the local variables, detect if someone logged in and simple add a prefix for the logged in user to use another storage path.

---

<div class="post-metadata">

**Author:** ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)\
**Post date:** [May 7, 2020, 7:19pm UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/4 "2020-05-07T19:19:08Z")

</div>

create a `defines.php` in the root of the cockpit folder. this file will get always loaded first:

> <https://github.com/agentejo/cockpit/blob/next/bootstrap.php#L43-L45>

here you can define eg. a custom `COCKPIT_ENV_ROOT` based on e.g `$_SERVER['SERVER_NAME']` to support multiple instances with one cockpit installation

---

<div class="post-metadata">

**Author:** ![bet0x](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@bet0x](https://discourse.getcockpit.com/u/bet0x)\
**Post date:** [May 25, 2020, 2:17am UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/5 "2020-05-25T02:17:22Z")

</div>

Can i grab the session in there? To make it based on the logged in user?

---

<div class="post-metadata">

**Author:** ![terencejackson8000](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/terencejackson8000/32/641_2.png) [@terencejackson8000](https://discourse.getcockpit.com/u/terencejackson8000)\
**Post date:** [June 11, 2020, 7:10pm UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/6 "2020-06-11T19:10:49Z")

</div>

I have not tried it but you should get the session id with  
`$session = session_id()`

For me it would be more interesting to fetch the user?  
Can this be done directly or do I need to get the token and then use this to fetch the user?

---

<div class="post-metadata">

**Author:** ![NeilCavendish](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@NeilCavendish](https://discourse.getcockpit.com/u/NeilCavendish)\
**Post date:** [September 4, 2020, 4:39pm UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/7 "2020-09-04T16:39:44Z")

</div>

+1 for me but mine would be just grouping of servers into tenants, as an MSP we maintain a bunch of servers for different clients so it would be nice to be able to split these up into groups within the same cockpit server.

any ideas on how i would do this now?

---

<div class="post-metadata">

**Author:** ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)\
**Post date:** [September 6, 2020, 5:25pm UTC](https://discourse.getcockpit.com/t/mutlitenancy-for-cockpit/1347/8 "2020-09-06T17:25:24Z")

</div>

@NeilCavendish Same here - wrong forum

> [@Update tab on the dashboard for managing server updates](https://discourse.getcockpit.com/t/update-tab-on-the-dashboard-for-managing-server-updates/1617/2):
>
> @NeilCavendish This forum is about the content management system “Cockpit CMS”, [https://github.com/agentejo/cockpit](https://github.com/agentejo/cockpit) Your issue/feature request is about about the server admin interface “Cockpit”, [https://github.com/cockpit-project/cockpit](https://github.com/cockpit-project/cockpit)
