UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Howto autostart ssh

    Scheduled Pinned Locked Moved Solved Support
    16 Posts 6 Posters 10.3k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • C Offline
        chris_bavaria
        last edited by

        I can´t solve the autostart service for the ssh server.
        I use OTA24 with second OS of VollaPhone22.

        I startet the ssh server:

        $sudo service ssh start
        $sudo systemctl is-enabled ssh
        enabled
        

        Checking for service to start on boot:

        $systemctl is-active ssh
        inactive
        

        To enable the service to start on boot, I gone to:

        $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
        

        My solution to read/write to root files:
        1.) Open UT Tweak Tool
        2.) go to System => make image writable => Temporary

        $sudo mount -o remount,rw /
        

        But no change:

        $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
        

        How can I enable ssh service on start?

        Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

        M 1 Reply Last reply Reply Quote 0
        • M Offline
          mark1250 @chris_bavaria
          last edited by

          @chris_bavaria

          systemctl enable ssh means to start the service at boot time. So if you reboot the phone after entering that the ssh server daemon would start.

          But, you don't have restart the phone to start the ssh server daemon, you can just enter
          systemctl start ssh

          If you want to do that in one step you can enter
          systemctl enable --now ssh

          C 1 Reply Last reply Reply Quote 0
          • C Offline
            chris_bavaria @mark1250
            last edited by

            @mark1250
            Thanks, but the service is not starting on boot. The service is not stored in update-rc.d because the error is:
            update-rc.d: error: Device or resource busy

            Is there a other solution or way to get access to the update-rc.d ?

            Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

            M 1 Reply Last reply Reply Quote 0
            • M Offline
              mark1250 @chris_bavaria
              last edited by

              @chris_bavaria
              Sorry, I for some reason thought you were on 20.04. I'm surprised that systemctl commands work on 16.04 which uses upstart hence the service command.

              Is something else using the port 22? Does the netstat command work? - I don't have quick access to a Ubuntu Touch install at the moment so I don't know if that command is available.
              netstat -tulnp

              C 1 Reply Last reply Reply Quote 0
              • C Offline
                chris_bavaria @mark1250
                last edited by

                @mark1250

                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!

                Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

                D C 2 Replies Last reply Reply Quote 0
                • D Offline
                  domubpkm @chris_bavaria
                  last edited by

                  @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

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    chris_bavaria @chris_bavaria
                    last edited by chris_bavaria

                    @chris_bavaria

                    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? 🙄

                    Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

                    1 Reply Last reply Reply Quote 0
                    • jezekJ Offline
                      jezek
                      last edited by

                      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

                      C 1 Reply Last reply Reply Quote 0
                      • C Offline
                        chris_bavaria @jezek
                        last edited by

                        @jezek
                        Yes, this is correct, there is nothing about systemctl.
                        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?

                        Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

                        jezekJ 1 Reply Last reply Reply Quote 1
                        • jezekJ Offline
                          jezek @chris_bavaria
                          last edited by

                          @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 be systemd, 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

                          C 1 Reply Last reply Reply Quote 1
                          • C Offline
                            chris_bavaria @jezek
                            last edited by chris_bavaria

                            @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? :frowning_face:
                            After the reboot I still get ssh stop/waiting from sudo status ssh. Am I missing something here?
                            A manual sudo service ssh start results in ssh 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/)

                            Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

                            jezekJ 1 Reply Last reply Reply Quote 0
                            • jezekJ Offline
                              jezek @chris_bavaria
                              last edited by

                              @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

                              C 1 Reply Last reply Reply Quote 0
                              • C Offline
                                chris_bavaria @jezek
                                last edited by

                                @jezek
                                Is ssh automatically activated when the phone starts?

                                Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

                                1 Reply Last reply Reply Quote 0
                                • BollyB Offline
                                  Bolly
                                  last edited by Bolly

                                  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.

                                  2015-Now (Daily use) : BQ Aquaris E4.5 Ubuntu edition
                                  2016-Now (Daily use) : BQ Aquaris M10 FHD Betatester

                                  2020-Now : PinePhone Braveheart & CE UBports
                                  2020-Now (Family/Daily use): Vollaphone Xenial
                                  2022-Now (Family/Daily use): Vollaphone 22 Focal

                                  C 1 Reply Last reply Reply Quote 1
                                  • C Offline
                                    chris_bavaria @Bolly
                                    last edited by

                                    @bolly
                                    THANK YOU SO MUCH ! 👏 :grinning_face: 👍
                                    Now runs after a reboot and is also available without unlocking the home screen.
                                    This is a real work simplification.

                                    Great work!

                                    Redmi Note 9 pro (UT 20.04 OTA-5) with Legion5 (Ubuntu 23.10)

                                    1 Reply Last reply Reply Quote 1
                                    • C chris_bavaria has marked this topic as solved on
                                    • RayCulpR RayCulp referenced this topic on
                                    • josevidalJ josevidal referenced this topic on
                                    • T Offline
                                      tonyr
                                      last edited by

                                      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).

                                      1 Reply Last reply Reply Quote 0
                                      • First post
                                        Last post