Page 1 of 1

Pairing to bluetooth using a password

Posted: Wed Jun 26, 2019 6:47 am
by antoinebore
Hi,

I want to connect my device (phone, computer..) to the Raspberry Pi Bluetooth without any access to the Raspberry Pi.

I have seen the solution bellow that automatically accept Bluetooth pairings but it's not safe and anybody can connect to the Raspberry Pi Bluetooth.

https://raspberrypi.stackexchange.com/ ... h-pairings

I was wondering if it's possible to connect a device to the Raspberry Pi using a password/pin code that we define before on the Raspberry Pi. That way, only people who know this password can connect to the Raspberry Pi Bluetooth. I'm not always using the same device to connect to the Bluetooth and setting all my devices as "trusted" is not an option for me.

It doesn't seem possible with bluetoothctl but maybe it's possible with a bash/python script ?

Re: Pairing to bluetooth using a password

Posted: Wed Jun 26, 2019 8:07 am
by antoinebore
I found this answer which works for me : https://stackoverflow.com/a/52164888


Create a configuration file :

Code: Select all

sudo nano /root/bluetooth.cfg
Edit the file configuration with the mac address and the pin code :
XX:XX:XX:XX:XX:XX 1234
Or if you want a pin to all the devices the same pin code, for example 1234, edit the file like this: * 1234

Then, run the bt-agent with your configuration file

Code: Select all

sudo hciconfig hci0 sspmode 0
sudo bt-agent -c NoInputNoOutput -p /root/bluetooth.cfg