# Using key pair to ssh into FX30

**URL:** <https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350>\
**Category:** FX30\
**Created:** [April 8, 2021, 8:40am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350 "2021-04-08T08:40:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [April 8, 2021, 8:40am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/1 "2021-04-08T08:40:02Z")

</div>

is there a way to use a keypair to ssh into the FX30?  
We would also like to remove the auto-login feature, this is to prevent people from logging in and copying our app.  
What is the best way to do so?

---

<div class="post-metadata">

**Author:** ![Donald](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Donald](https://forum.sierrawireless.com/u/Donald)\
**Post date:** [April 8, 2021, 9:05am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/2 "2021-04-08T09:05:45Z")

</div>

Hi @claudio.baldini ,

We have the similar topic matching with your request. Please refer to below for detail.

> [@Public key authentication with ssh](https://forum.sierrawireless.com/t/public-key-authentication-with-ssh/9680/4):
>
> The problem was due to insecure file system permissions. Here is a list of commands that generates the key and sets the right permissions (the hardest to find was the first): dropbearkey -t rsa -f ~/.ssh/id\_rsa | grep ssh-rsa \> .ssh/authorized\_keys chown root /home/root chmod 700 /home/root chmod 700 ~/.ssh chmod 600 ~/.ssh/id\_rsa chmod 600 ~/.ssh/authorized\_keys The '/etc/dropbear/authorized\_keys ’ file is uneccessary. Do use the dropbearkey command to generate the key-pair though. IMPORTANT:…

Thanks,

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [April 12, 2021, 2:05am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/3 "2021-04-12T02:05:50Z")

</div>

cheers @Donald we would also need to completely eliminate the possibility of logging to the device without the key-pair, so no user or root should be able to get into to device and to see/read/copy the binary.

I have also seen a possible problem and requirement to switch back to a different user before a firmware update:  
**IMPORTANT: Since the owner of /home/root is ‘appfwupdateService’ by default, for safety reasons you shoud switch back to this user and default permissions (755) before doing a firmware update.**

We would need to remotely download the firmware and this may not be possible/easy to achieve…

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [April 15, 2021, 5:50am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/4 "2021-04-15T05:50:42Z")

</div>

Hi @claudio.baldini ,  
You can disable user logins by changing the dropbear configuration in /etc/default/dropbear

I recommend you build your own yocto image with the change applied within your workspace. If you manually modify the file, it will be present in the overlay and subject to being deleted upon factory reset via the pushbutton.

BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [April 15, 2021, 7:41am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/5 "2021-04-15T07:41:32Z")

</div>

ok, we are using the system build with legato, so possibly I can modify it manually (/etc/default/dropbear), backup the file and then to implement it into my system to be downloaded to the target when I download the app to it?

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [April 16, 2021, 3:36am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/6 "2021-04-16T03:36:28Z")

</div>

It’s not clear from your statement how to plan to implement the change.

Some options are:

1. Add a recipe into a yocto workspace and build the full image, including your application
2. Add the dropbear configuration within you Legato app (make sure you also restart dropbear)
3. Manually perform the change which is subject to factory reset

BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [April 17, 2021, 1:46am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/7 "2021-04-17T01:46:38Z")

</div>

I would like to implement the option 2. How can I configure dropbear from my app? Would u be able to point me out to any example?

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [July 22, 2021, 7:51am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/8 "2021-07-22T07:51:37Z")

</div>

now that I can build the source, is there any reference to option 1 so to add the login through key-pair and to disable the password login?  
wonder if this was already discussed in a different post so I can start from there.

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [July 28, 2021, 2:46am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/9 "2021-07-28T02:46:19Z")

</div>

Hi @claudio.baldini,  
You’ll have to do it in 2 steps:

1. Install your authorized\_keys into the root filesystem somewhere. You can create a recipe that looks something like this:

```auto
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += " \
            file://authorized_keys \
           "

do_install_append() {
    install -m 0755 ${WORKDIR}/authorized_keys -D ${D}/${sysconfdir}/authorized_keys
}

```

1. Create a startup script to copy the authorized\_keys to the /home/root/.ssh folder:

```auto
    # copy authorized_keys
    if [! -d /home/root/.ssh]; then
        mkdir -p /home/root/.ssh
    fi

    if [! -e /home/root/.ssh/authorized_keys]; then
        cp /etc/authorized_keys /home/root/.ssh/
    fi

```

1. Install your startup script from one of your recipes

```auto
do_install_append() {
    install -m 0755 ${WORKDIR}/myscript.sh -D ${D}${sysconfdir}/init.d/myscript.sh

    [-n "${D}"] && OPT="-r ${D}" || OPT="-s"
    update-rc.d $OPT -f myscript.sh remove
    update-rc.d $OPT myscript.sh start 60 S . stop 60 S .
}

```

BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [August 31, 2021, 1:14am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/10 "2021-08-31T01:14:22Z")

</div>

I have created a recipe “customssh” in swi-linux-src/meta-swi/common/recipes-core/customssh/customssh\_0.1.bb:

FILESEXTRAPATHS\_prepend := “${THISDIR}/files:”  
LICENSE=“MIT”

SRC\_URI += "   
file://authorized\_keys   
"

do\_install\_append() {  
install -m 0755 ${WORKDIR}/authorized\_keys -D ${D}/${sysconfdir}/authorized\_keys  
install -m 0755 ${WORKDIR}/myscript.sh -D ${D}${sysconfdir}/init.d/myscript.sh  
[-n “${D}”] && OPT="-r ${D}" || OPT="-s"  
update-rc.d $OPT -f myscript.sh remove  
update-rc.d $OPT myscript.sh start 60 S . stop 60 S .  
}

in the “files” folder I have copied the authorized\_keys and my\_script.sh  
Compiled from source but it still seems going through the password…

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [August 31, 2021, 3:25pm UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/11 "2021-08-31T15:25:45Z")

</div>

Hi @claudio.baldini,  
When you ssh to your device, do you specify -i \<your\_public\_key\>?  
BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [September 1, 2021, 3:14am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/12 "2021-09-01T03:14:34Z")

</div>

should the recipe download the files to the target?  
because I am checking the /etc and /etc/init.d folders and can`t see either the keys nor the script…

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [September 2, 2021, 7:09am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/13 "2021-09-02T07:09:12Z")

</div>

I think you are missing myscript.sh in the SRC\_URI

You can also verify your recipe is working properly by ensuring the files are installed into the target rfs here:  
/build\_bin/tmp/work/swi\_mdm9x28\_fx30-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/rootfs/etc

BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [September 2, 2021, 7:38am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/14 "2021-09-02T07:38:15Z")

</div>

yeah, I had that fixed:  
FILESEXTRAPATHS\_prepend := “${THISDIR}/files:”  
LICENSE = “mit”

SRC\_URI = “file://authorized\_keys”  
SRC\_URI += “file://myscript.sh”  
do\_install() {  
install -m 0755 ${WORKDIR}/authorized\_keys -D ${D}/${sysconfdir}/authorized\_keys  
install -m 0755 ${WORKDIR}/myscript.sh -D ${D}${sysconfdir}/init.d/myscript.sh  
[-n “${D}”] && OPT="-r ${D}" || OPT="-s"  
update-rc.d $OPT -f myscript.sh remove  
update-rc.d $OPT myscript.sh start 60 S . stop 60 S .  
}

but can`t see the file in the directory you have mentioned.  
swi-linux-src/build\_bin/tmp/work/swi\_mdm9x28\_fx30-poky-linux-gnueabi/mdm9x28-image-minimal/1.0-r0.0/rootfs/etc  
none of them, the myscript.sh should be inside the init.d but is not.

my recipe is placed in the:  
swi-linux-src/meta-swi/common/recipes-core/customssh  
where customssh is my recipe and the name is customerssh\_0.1.bb is the name of bybitbake recipe

I can compile with no problem, but the files do not show up…

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [September 28, 2021, 5:32am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/15 "2021-09-28T05:32:20Z")

</div>

Hi @claudio.baldini,

You can debug your recipe by checking it’s the temp folder in that is generated within the recipe workspace. In your case, it should be in:

```auto
build_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/customssh/0.1_0/temp

```

Within the “temp” folder, check the log.task\_order to view the list of tasks that are run for your recipe.

If you don’t see the do\_install task, you may need to do an “addtask”.

Also, you may need to change your recipe name to match the recipe folder.

BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [October 4, 2021, 12:46am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/16 "2021-10-04T00:46:36Z")

</div>

@cchenry I can’t find this folder, the recipe name (customssh\_01.bb) is matching the folder (customssh), this has been added to the swi-linux-src/meta-swi/common/recipes-core folder.  
The recipe is definitely built, as if I omit the license the built will fail, and if I specify the wrong filename I will get a warning.  
However, after building the yocto image, I can`t see anything in the folder you have mentioned:  
build\_bin/tmp/work/armv7a-neon-poky-linux-gnueabi/customssh/0.1\_0/temp

The customssh just doesn’t exist.

Is the swi-linux-src/meta-swi/common/recipes-core the right folder where to place the recipe?

---

<div class="post-metadata">

**Author:** ![cchenry](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cchenry](https://forum.sierrawireless.com/u/cchenry)\
**Post date:** [October 7, 2021, 6:41am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/17 "2021-10-07T06:41:11Z")

</div>

Hi @claudio.baldini,  
You need to figure out why your recipe isn’t being parsed.

Try running these commands:

make dev  
bitbake-layers show-recipes

Then check if your recipe is listed. It’s possible the conf file isn’t parsing the same string type that matches the format of your recipe name.

You may need to modify the conf file or you could try moving it elsewhere.

BR,  
Chris

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [October 7, 2021, 7:03am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/18 "2021-10-07T07:03:29Z")

</div>

@cchenry thanks, the recipe seems to be parsed properly:  
customssh:  
common 01

but after I have baked, it doesn`t show anywhere as running this command

swi-linux-src$ find . -name _customssh_

only returns the folder and the files

./swi-linux-src/meta-swi/common/recipes-core/customssh  
./swi-linux-src/meta-swi/common/recipes-core/customssh/customssh\_01.bb

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [October 18, 2021, 6:58am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/19 "2021-10-18T06:58:46Z")

</div>

@cchenry I have also tried to place the recipe in this folder, the recipe is listed if I use the command you have sent, but files and folders are still not created.  
This is not top priority on our list but it would be nice to fix if we could…

---

<div class="post-metadata">

**Author:** ![claudio.baldini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@claudio.baldini](https://forum.sierrawireless.com/u/claudio.baldini)\
**Post date:** [October 21, 2021, 5:11am UTC](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350/20 "2021-10-21T05:11:04Z")

</div>

@cchenry but I was wondering, even after we have implemented this, will this prevent from hard resetting the device with the RESET button and to specify a new login password?  
I understand we can disable that functionality with an AT command, but then if we have any problem with the applications we have designed, how can we recover?

[Next page](https://forum.sierrawireless.com/t/using-key-pair-to-ssh-into-fx30/23350.md?page=2)
