1

I would like to be able to ssh into my RPi3B+ based robot (running Ubuntu 20.04 64-bit Server) when away from my home WiFi.

I have configured the bot to recognize either my home network or my iPhone hotspot network.

/etc/netplan/50-cloud-init.yaml:

network:
    ethernets:
        eth0:
            dhcp4: true
            optional: true
    version: 2
    wifis:
        wlan0:
            access-points:
                SSIDHOME:
                    password: pwhome
                SSIDHOTSPT:
                    password: pwhotspot
            dhcp4: true
            optional: false

I see that the bot successfully connects to the hotspot.

Launching Termius on the iPhone, I created a host with the hostname of the bot - "ROSbot".

Clicking on the bot in Termius:Hosts shows "(ROSbot:22) Username / Select Identity" dialog, to which I select the desired identity (username/password) on the bot.

Termius reports:

Connection could not be established:
Connecting...
Disconnected
Connection closed with error: unknown node or service

Looking in the /var/log/auth.log there are two sshd entries:

Oct  3 10:24:56 ROSbot sshd[1921]: Server listening on 0.0.0.0 port 22.
Oct  3 10:24:56 ROSbot sshd[1921]: Server listening on :: port 22.

but no successful or failed login attempts are listed like when I remote in when the bot is connected via my home WiFi:

Oct  3 10:41:48 ROSbot sshd[2319]: Accepted password for pi from XX.0.0.XXX port XYZ ssh2
Oct  3 10:41:48 ROSbot sshd[2319]: pam_unix(sshd:session): session opened for user pi by (uid=0)

Any ideas how to debug what is happening and get this to work?

2
  • 1
    Hopefully you can do the equivalent of ssh -vv with Termius which would go a long way in identifying the problem, because to me this looks like it is 100% an iOS issue and has nothing much to do with the Raspberry Pi...
    – goldilocks
    Commented Oct 3, 2021 at 15:38
  • @goldilocks interesting thought - Termius doesn't allow ssh options. I'll try posting also on the apple iphone forum. Commented Oct 3, 2021 at 17:10

2 Answers 2

0

Found a solution:

  • install the iNet Pro app
  • after bot connects to hotspot, run iNet Pro network scan to determine the bot IP
  • Tell Termius the bot's hostname is that IP
  • ssh to the bot, authorize the unknown key, and I'm in!
0

In the ensuing year the iNet Pro app stopped working to show the iPhone hotspot clients.

What I have found good is to create a service that uses text-to-speech to read the IP address at boot to an attached speaker on my robot.

This takes the form of /home/ubuntu/utils/ip_feedback.sh

$ more ip_feedback.sh 
#!bin/bash

# FILE:  ip_feedback.sh
# This script is run once at boot by ip_feedback.service

echo "starting"
COUNT=0
IPs=$(hostname --all-ip-addresses)
while [ -z "$IPs" ]
do
    echo "loop"
    sleep 1;
    IPs=$(hostname --all-ip-addresses)
    COUNT=$((COUNT+1))
    echo "count: "$COUNT > /home/ubuntu/ipcount
done

echo "done looping "

echo "count: "$COUNT > /home/ubuntu/ipcount

ifconfig wlan0 | grep 'inet ' | awk '{print $2}'  > /home/ubuntu/ip.number
read -r IP_NUMBER < /home/ubuntu/ip.number
echo $IP_NUMBER

# remove previous IP info
sudo rm /boot/*.assigned_ip &>/dev/null
# sudo rm /home/pi/Desktop/*.assigned_ip &>/dev/null

# remove previous Failed IP
FAILED=/home/ubuntu/failedIP
if test -f "$FAILED"; then
    sudo rm $FAILED &>/dev/null
fi
# sudo rm /home/pi/Desktop/failedIP &>/dev/null

if [ ! -z "$IP_NUMBER" ]
then
        echo "saving IP info"
        sudo bash -c "echo $IP_NUMBER > /boot/$IP_NUMBER.assigned_ip"
#       echo $IP_NUMBER > /home/ubuntu/Desktop/$IP_NUMBER.assigned_ip
        echo "IP info saved"

        su -c "espeak-ng 'WiFi IP'" pi
        su -c "espeak-ng $IP_NUMBER" pi
        su -c "espeak-ng repeating "  pi
        su -c "espeak-ng $IP_NUMBER" pi
else
#       espeak-ng "no IP number"
        echo "no IP number"
        echo "no IP" > /home/ubuntu/failedIP
#       echo "no IP" > /home/ubuntu/Desktop/failedIP

fi
echo "done with IP feedback"

and the service definition /etc/systemd/system/ip_feedback.service:

[Unit]
Description=IP Feedback on Boot
After=syslog.target network.target


[Service]
Type=simple
user=pi
WorkingDirectory=/home/ubuntu
ExecStart=/bin/bash /home/ubuntu/utils/ip_feedback.sh

[Install]
WantedBy=multi-user.target

and running the commands:

  • chmod 777 ip_feedback.sh
  • sudo systemctl daemon-reload
  • sudo systemctl enable ip_feedback
  • sudo service ip_feedback start

Now every boot announces the WiFi IP.

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.