I am currently writing a program that detects if an IoT is compromised (i.e sending information its not supposed to). When this behaviour is detected by the control server, it will then get the device to reset by downloading its uncompromised code functions (which i have on a cloud) and running them. Is there a way to do this. Im using nodejs on my raspberry by the way.
Is there a way to shutdown or reboot a raspberry pi via a script?
You can issue the command:
ssh <user>#<ip address to Pi> 'echo <password> | sudo <full path to shutdown command> -r now'
Replace with the Pi's username, replace with the password, and that path to shutdown (which you can find while connected to the Pi do which shutdown). And fill in the IP address to your PI.
That should reboot your Pi.
Related
Setup:
Embedded target device: Rock5B (ARM64)
Linux: Debian 11
Bluetooth stack: Bluez
Audio: Pulseaudio
Window environment: Xfce
I'm writing a Bluetooth application which connects to a headset.
If I manually log into window environment with user credentials and do manual Bluetooth pairing and select manually the output sink it does work as expected.
The same happens if I log into window environment and I run my application remotely using SSH which connects to Bluetooth headset and run the script remotely using SSH and selecting the output sink number 3 (which in that case is Bluetooth headset):
pacmd set-default-sink 3.
On the other hand if the device get started but I do not log into window environment but instead just run same steps remotly using SSH then Blutooth pairing is completed but the Pulseaudio sink number 3 is not present.
I have tried after restart to first run the Pulseaudio manually:
pulseaudio -k
pulseaudio -D
and after that I have run remotely using SSH my app and then select the sink with pacmd. Now pacmd found and selected the sink but when I tried to run the audio file remotely there was no audio output:
PULSE_SERVER=127.0.0.1 cvlc audo.wav
Again if I log into the window environment run everything remotely and run above cvlc the audio is working fine.
Something needs to be setup more than that when windows environment is starting but I can not figure what.
I need to run a gui-based application on a remote PC to which I am connected over telnet. The remote PC runs Linux Ubuntu 18.04
To figure out the screen, I run the following command on the remote machine:
echo $DISPLAY
which gave me :1 as result.
Then I run the program on the remote machine from my client (over telnet) using:
DISPLAY=:1 application_name
The program started correctly (since, in addition to the GUI, it prints some things on the command line) but the GUI didn't show up. But, if I run my app directly on the remote machine, everything is fine.
As a test, I tried to run firefox browser on an another machine (always through telnet) with the following command:
DISPLAY=:0 firefox
and it worked. Note: on the other machine the output of echo $DISPLAY was :0. Furthermore, I could not test my app on the second machine.
It seems that there are different settings between the two machines since what I'm trying to do works on a machine, but not on the other.
Do you have any idea of what type of setting should I check?
Did you try to run your application on the first remote machine but with DISPLAY=:0 instead of :1?
What is the error message you get from application when you started application in the first case ("DISPLAY=:1 app_name").
I'm trying to enable the bluetooth OPP profile in my linux machine(Ubuntu-16.04 LTS) to connect it with android phone.
Initially I enabled the bluetooth interface using the command, /etc/init.d/bluetooth start
Began to scan for the devices to connect, using the hcitool scan that displays both device 'Bluetooth MAC address and Username'
I paired my PC with the device (Redmi note 4-Android Nougat) using the command hcitool cc --role=s <br_addr>
Then I executed the command the sudo obexctl, which lead to the interactive mode,
[obex]# connect <br_addr>
On connecting to the device using its bluetooth MAC address, following error is thrown,
Client proxy not available
Hope this link would be useful as it explains what the exact output is supposed to be like.
https://docs.ubuntu.com/core/en/stacks/bluetooth/bluez/docs/reference/sending-files
Yes, I just now figured out the answer for my own question(thought to leave the question undeleted as it may help someone encountering the same situation)
Before intialising the bluetooth services, got to run the daemon,
sudo service bluetooth stop
sudo systemctl daemon-reload
sudo service bluetooth start
sudo hciconfig -a hci0 reset
So now good to go, the obexctl command can be executed. Once entered into the interactive mode, connections can be made and the file could be pushed or pulled as mentioned in the link.
I installed an ubuntu server with openssh server on a virtualbox and it works fine. when I start it from GUI I can access it via ssh and Putty, there is no problem. When I start it In headless mode from virtualbox gui there is no problem either.
the problem is, when I run it using VBoxManage startvm "Ubuntu" --type headless it returns a message saying that the Ubuntu is running in headless mode but when I want to connect via ssh to it, its not accessable. my host os is windows 10 and the ubuntu server name is "Ubuntu" and os version is ubuntu-16.04.2-server-x64 and I installed openssh-server and dkms as it described here: https://www.htpcbeginner.com/install-virtualbox-guest-additions-on-ubuntu-debian/
when I work in GUI evrything is fine but I want to run it from windows command line to save some time.
It looks like that the command line vm "Ubuntu" is diffrent from GUI vm "Ubuntu". But I have only one vm on virtualbox. in gui there is one and in cmd vboxmanage list vms returns one vm. so what is the problem?
I also added virtualbox guest addition from Device menu in virtualbox GUI
Edit:
I saw another command : VBoxHeadless --startvm "Ubuntu" its not working either. but unlike the last command it does not show message that Ubuntu is Running. actually it will stuck in execution and the cursor turns to a blinking dash for ever. so I should close the cmd to get ride of it.
I checked something. If I use NAT on network adapter and port forwarding, it works even from cmd. but when using bridge to avoid using port forwarding its not working. in the bridge mode there is connection and ping is working but cant ssh to the Ubuntu.
I found the solution. the solution is I should keep the NAT interface as primary as is by default and make a secondary interface in virtualbox gui settings. the secondary interface should be Host-only. then by using this question and its answer I added an interface to guest Ubuntu to a static address. now I can ssh to the static Ip address even if I run the vm from command line, and there is no need to port forwarding.
I'm relatively new to the Raspberry Pi and am trying to receive data via Bluetooth on my Raspberry Pi. I've opted to use obexpushd and have installed all the bluetooth packages needed. However, when I run the command
obexpushd -B -n
to initialize obexpushd and have it listen to any incoming Bluetooth messages, it gives me this error message:
Listening on bluetooth/[00:00:00:00:00:00]:9
SDP session setup failed, disabling bluetooth
net_init() failed
I'm pretty sure that I've paired and connected the Raspberry Pi and device correctly so I'm at a loss for why it's not working.
You have an issues with your bluetooth sdp. Try stopping it
$ sudo service bluetooth stop
And restart it
$ sudo bluetoothd --compat
I had the same issue and it worked for me.
Subert's Answer Worked for me, I was wondering that hci was not discoverable.
In addition of Subert's Answer:
service bluetooth stop
bluetoothd --compat &
obexpushd -B -n &
For me the hciconfig was down, so i started it as:
hciconfig hci0 up
Now every thing is fine,
Thanks for subert's Answer.
Though #Subert is correct, a better way to run the daemon in compat mode is to extend the systemd script. This solution allows you to use the start/stop scripts and will survive any updates.
Create the file /etc/systemd/system/bluetooth.service.d/compat.conf with the following:
[Service]
ExecStart=/usr/lib/bluetooth/bluetoothd —compat
I decided to name the file compat.conf but you can name it whatever you want.
Reload & restart the daemon, and you're done!
$ sudo systemctl daemon-reload
$ sudo service bluetooth restart
I didn't have to run the hciconfig command but do have to run obexpushd as root (using sudo) until I figure out a better way.