Howto autostart ssh
-
phablet@ubuntu-phablet:~$ netstat -tulnp (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN - udp 0 0 127.0.1.1:53 0.0.0.0:* - udp 0 0 0.0.0.0:68 0.0.0.0:* -
After I start the ssh service manually the output is:
$sudo service ssh start phablet@ubuntu-phablet:~$ netstat -tulnp (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp6 0 0 :::22 :::* LISTEN - udp 0 0 127.0.1.1:53 0.0.0.0:* - udp 0 0 0.0.0.0:68 0.0.0.0:* -
I get access via ssh, but the service is not starting on boot.
Yes, I use the VollaPhone22 with Ubuntu 16.04 (OTA-24).
In the next days, I get my new phone Pixel 3a. I go to install 20.04 and try this with my new phone. Maybe this is a issue with the port of VollaPhone22?
Thanks, I report then here my experience! -
@chris_bavaria said in Howto autostart ssh:
Maybe this is a issue with the port of VollaPhone22?
You can ask here : https://github.com/HelloVolla/ubuntu-touch-beta-tests/issues
-
The same on Pixel 3a (OTA24)
$sudo systemctl enable ssh Synchronizing state of ssh.service with SysV init with /lib/systemd/systemd-sysv-install... Executing /lib/systemd/systemd-sysv-install enable ssh update-rc.d: error: Device or resource busy
Why is device or resource busy?
-
In the user guide about how to start ssh for 16.04, there is nothing about the
systemctl
command. I don't recall to use such command when enabled ssh on my FP2 a long time ago (it works after reboots). Does Vollaphone handle it differently? -
@jezek
Yes, this is correct, there is nothing aboutsystemctl
.
Enabled ssh is after reboot disabled on VollaPhone, same on Pixel 3a with 20.04 (2022-W51).
Is there a solution to turn ssh service on, while booting? -
@chris_bavaria said in Howto autostart ssh:
Is there a solution to turn ssh service on, while booting?
Hmm... if there is
systemctl
, then there has to besystemd
, am I right? And if there is a systemd, then you can write a user service, which will run at boot.If there is no
systemd
, then it is using upstart and you can make it run script on boot.If everything fails try cron job on boot.
-
@jezek
Thanks for the explanation.
I've now read deeper and found the command for ssh in runlevel3.
This points to /etc/init.d. This is the script that starts the "OpenBSD Secure Shell server" at boot time.
According to my research, the settings for the autostart are made in /etc/init.
Since I don't want to change the script, but just want to start the service, I've included
sudo update-rc.d ssh defaults
enabled the shh service (again).
After that I got this output with the following command:phablet@ubuntu-phablet:~$ service --status-all ... [ + ] apparmor [ + ] isc-dhcp-server [ - ] keyboard setup ... [ + ] network manager [ + ] networking ... [ - ] rc.local ... [ + ] ssh [ + ] udev ...
Although ssh is shown as an active here, I can't access UbuntuTouch 16.04 from my client.
ssh: connect to host 192.168.188.50 port 22: Connection refused
In the systemctl I found the ssh.socket with the following command. However, this ssh.socket is not executable.
$systemctl list-unit-files --type=socket UNIT FILE STATE ... ssh.socket enabled ... systemd-networkd.socket disabled ...
I need to run the
sudo service ssh start
command manually to get access via ssh.I found the startup script for ssh.service under /lib/systemd/system and it already exists.
When I run the existing ssh.service command to enable it, I get the following error:root@ubuntu-phablet:/lib/systemd/system# systemctl enable ssh.service Synchronizing state of ssh.service with SysV init with /lib/systemd/systemd-sysv-install... Executing /lib/systemd/systemd-sysv-install enable ssh update-rc.d: error: Device or resource busy root@ubuntu-phablet:/lib/systemd/system# systemctl status ssh Failed to get properties: No such interface ''
I see the problem in the following line:
update-rc.d: error: Device or resource busy
Is this service locked in UbuntuTouch?
After the reboot I still getssh stop/waiting
fromsudo status ssh
. Am I missing something here?
A manualsudo service ssh start
results inssh start/running, process 7838
.
Can someone confirm that the ssh service doesn't start automatically?I'll try it now with cron job on boot, hopefully it works. But it's not such a clean solution.
( upstart works together with systemd > https://crunchify.com/systemd-upstart-respawn-process-linux-os/)
-
@chris_bavaria I have an FP2. I've enabled ssh long time ago, using the documentation mentioned above. The only trouble I have with ssh, is that when I enable wifi on the phone and want to connect to it (from notbook using ssh), many times the connection doesn't get through. I have to reconnect the wifi on the phone (by tapping on the connected wifi name in wifi notification area) and than it connects. No need to start service in the phone terminal.
-
@jezek
Is ssh automatically activated when the phone starts? -
Hi, it's probably a botched job. I'm sorry.
SSH does not start automatically on Pinephone and Vollaphone 22. It may happen on more devices, I don't know.
To solve it I created this "thing" when I played with Pinephone.
Script enabledSSH.sh
#!/bin/bash ### Enable SSH at startup in UT ### echo "#!/bin/bash" > startssh.sh echo "### Iniciar SSH ###" >> startssh.sh echo "exec service ssh start" >> startssh.sh sudo chmod +x startssh.sh sudo mount -o remount,rw / sudo cp startssh.sh /etc/init.d/ sudo rm startssh.sh sudo update-rc.d startssh.sh defaults sudo reboot
Then execute:
bash enabledSSH.sh
P.S. Rerun only when changing channels.
-
@bolly
THANK YOU SO MUCH !
Now runs after a reboot and is also available without unlocking the home screen.
This is a real work simplification.Great work!
-
-
-
-
I'm new, also running UbuntuTouch 16.04 as of this morning.
I'm wondering why this doesn't work 'out of the box', we have a
/etc/init.d/ssh
and it's active for the run levels we want. I've spent some time trying to trace this, without luck.The standard hack is to put stuff in
/etc/rc.local
, so that's what I did in the end (service ssh start
).