rfkill: cannot open /dev/rfkill - Permission denied in SSH session (foxy)
Hi, I am working with ROS2 foxy distribution. I have written a python logic which connects my PS4 controller with Jetson.
Below is my logic:
https://gist.github.com/egorf/66d8805... - Bluetooth class
bt = Bluetoothctl()
bt.connect(PS4_MAC_ADDRESS) #PS4_MAC_ADDRESS - My PS4 MAC address
I have a created a package and a node which would call a python program containing the above logic. Like this:
ros2 run bluetooth_pkg test
This works perfectly when I connect and access the Jet son device using HDMI port(meaning using a UI). But when i try to ssh into the device and run the same code, it keep throwing me this error - rfkill: cannot open /dev/rfkill - Permission denied
I went through forums and checked soft and hard blocks. Its all unblocked. Restarting the Bluetooth also dint work. Why does running a ros2 node through ssh fail?
I found this link: https://answers.ros.org/question/1652... Do I have to do a similar approach? Any directions would be appreciated.
Thanks and Regards Niranjan
I've changed the title of your question to describe what you observe, not what you believe is the cause (ie: "sudo problem").
Additionally: this looks like a non-ROS issue at the moment.
I would suggest to see whether you can replicate the issue without ROS in the mix (ie: start a script in a regular terminal vs via an SSH connection).
Hi, thanks for your help. Starting the script in regular terminal works fine with and without ROS.
SSH without ROS works fine.
But SSH with ROS is where the issue occurs.
I can't really give you any solid advice on the best way to deal with this, but I think I can explain what's happening. The mechanism that's enforcing access control on
/dev/rfkill
is known as "uaccess", and it is designed to restrict access to some hardware interfaces on the system to local terminals only. Another example of an interface that is restricted over a remote terminal is the ability to shutdown or reboot the system, which doesn't need to be elevated when invoked from a local terminal but requires elevation from a remote terminal.Invoking the command using
sudo
should get you past that error. You could also temporarily change the permissions on the/dev/rfkill
device file (again, using sudo) to allow your user to write to it without going through the ACLs governed by uaccess. This would, of course, circumvent security measures, so ...(more)Hi, Yes I was trying to follow the above comment. It turned out very complex. Currently, I use sudo -s command before running the bluetooth package and it runs successfully.