0

I've done some Googling and, so far, none of the answers I've found fit my use case for one reason or another.

What am I trying to achieve? I want my Raspberry Pi 2B+, at boot, to SSH automatically into one host running on my network and launch the command bpytop on said host. The host is running Lubuntu 22.04 and already has bpytop installed, while the Raspberry is running a headless version of the latest Raspberry Pi OS 32bit (/etc/*release says it's version 11, on kernel 6.1.21-v7+). I have already set up keyless SSH into the host, and that works just fine; the Raspberry is also connected to a 5" HDMI display.

What doesn't work fine is everything else. I've tried, as a test, to configure crontab so that it SSH at reboot into the host; that doesn't work, and I'm realising now it might be because jobs in crontab are not displayed to the monitor attached.

Of course, doing all of this manually works just fine, as in I can SSH into the host, then launch bpytop and see all of its glorious data.

My question is: is this actually achievable, having the Pi doing all of this at boot without user intervention?

EDIT: For clarification, here's the latest crontab command I've tried:

#Automatic SSH in into Lubuntu server at reboot
@reboot sleep 30 && bpytop | ssh -i /home/pi/.ssh/pi-monitor USR@IPADDR > /dev/tty1

I was trying without /dev/tty1, and of course the display was just showing the Pi terminal. Now that I'm passing the command to tty1, here's what I'm greeted with (sorry for the screen picture, but the issue is with what's on the actual display). That Welcome to Ubuntu message is the MotD of the host I want to connect to, so that's a start. However, bpytop is not being executed, and pressing any key on the keyboard will just bring me back to the Pi console.

2
  • Yes, it's achievable, but you should post the actual command or script you are trying to execute (and the method of execution, ie., the actual crontab entry) if you want to know what is wrong with it.
    – goldilocks
    Commented Aug 1, 2023 at 15:05
  • @goldilocks Ah you're right, I've expanded a bit more about it now, hopefully it's more clear.
    – vale.maio2
    Commented Aug 1, 2023 at 17:35

1 Answer 1

0

I'm not a cron user but this looks wrong:

 sleep 30 && bpytop | ssh -i /home/pi/.ssh/pi-monitor USR@IPADDR > /dev/tty1

Interpreted as a shell command, that's execute sleep 30 then bpytop on the local machine and pipe the output (|) to ssh, which is just a login, and while ssh reads from stdin, this is usually for passing that output to a remote command, and there isn't one here (in the example from that link, it's taring stuff locally to stdout, then passing that output through ssh's stdin, which passes it for tar to extract on the remote host).

If you want to ssh in and execute bpytop on the remote machine, as per man ssh you can add a command after USR@IPADDR. So:

sleep 30 && ssh -i /home/pi/.ssh/pi-monitor USR@IPADDR bpytop > /dev/tty1
  
2
  • First of all, thank you for your reply. Unfortunately this is not working, the Pi just sits at its own terminal page, without any signs of the connection to the host. When testing it through a PuTTy session, I get the error bash: line 1: bpytop: command not found as if it was trying to execute bpytop on the Pi rather than the host
    – vale.maio2
    Commented Aug 1, 2023 at 18:17
  • sleep 30 && ssh -i /home/pi/.ssh/pi-monitor USR@IPADDR ./bpytop > /dev/tty1
    – bstipe
    Commented Sep 5, 2023 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.