Security

"Can't create directory" on add monitor

davisyoshida
Engager

I am running the command
sudo -u splunk ./splunk add monitor /var/log/

When I do this, I receive the error 'Can't create directory "/home/myusername/.splunk": Permission denied.' Seeing as the command is being run as the splunk user, I can't see why it would be trying to make a directory in my home directory. Why is this happening, and how can I fix it?

Tags (2)

Trucal
New Member

I had the same issue using 'sudo -u splunk splunk ./splunk add monitor /var/log/' to add a monitor. I ended up adding .splunk directory to my home and running chmod 777 on it.

The add-monitor script added an authToken_servername_8089 to my normal user home directory, but owned by splunk:splunk,

0 Karma

mattspierce
Explorer

When you start your forwarder do you run the init or call the program via the splunk user or the root user?. My guess would be that you called it form root and your permissions are for the root user. If you do an ls -la you can see who owns the files. I would approach the problem as user root run chown -R splunk:splunk /opt/splunkforwarder/ then ensure you start the forwarder as splunk. Your sudo -u splunk should now be able to make the necessary changes.

0 Karma

seandevo
Explorer

I had the same problem, try just typing:

sudo ./splunk add monitor /var/log/

It should prompt you for root [sudo] password and then your splunk credentials that were set up. Worked for me

Good luck!

0 Karma
Get Updates on the Splunk Community!

Splunk Lantern | Spotlight on Security: Adoption Motions, War Stories, and More

Splunk Lantern is a customer success center that provides advice from Splunk experts on valuable data ...

Splunk Cloud | Empowering Splunk Administrators with Admin Config Service (ACS)

Greetings, Splunk Cloud Admins and Splunk enthusiasts! The Admin Configuration Service (ACS) team is excited ...

Tech Talk | One Log to Rule Them All

One log to rule them all: how you can centralize your troubleshooting with Splunk logs We know how important ...