Unable to implement User Impersonation on Enterprise Gateway

I am trying to configure user impersonation on JEG installed on a standalone VM.

Here is my run.sh to start Enterprise Gateway.

jupyter enterprisegateway --ip= --port=8899 --port_retries=0 --log-level=DEBUG --EnterpriseGatewayApp.allow_origin=* --EnterpriseGatewayApp.list_kernels=true --RemoteKernelManager.cull_idle_timeout=43200 --MappingKernelManager.cull_interval=60 --MappingKernelManager.cull_connected=True --EnterpriseGatewayApp.impersonation_enabled=true --EnterpriseGatewayApp.remote_hosts=[‘localhost’] > $LOG 2>&1 &

Where EnterpriseGatewayApp.impersonation_enabled=true –

And Here is a curl that includes KERNEL_USERNAME

curl --location --request POST ‘’ --header ‘Content-Type: application/json’ --data-raw ‘{ “name”: “python”, “env”: { “KERNEL_USERNAME”: “dnsmasq” } }’

But the kernels are always getting launched by the Enterprise Gateway user which is dc-user in my case:

However in the enterprise_gateway.log I can see the following logs

[D 2024-02-20 14:07:33.481 EnterpriseGatewayApp] Kernel args: {‘env’: {‘KERNEL_USERNAME’: ‘dnsmasq’}, ‘kernel_headers’: {}, ‘kernel_name’: ‘python’}

What configuration changes do I need to make, to run the kernels by the usesid given in the KERNEL_USERNAME.