Search code examples
linuxgitsshyocto

Yocto fetch from local git server


I'm using Yocto, and I want to be able to fetch the source code from a local git server which is another machine on my network.

This command works just fine through the terminal

git clone git@192.168.30.58:/home/git/linux-imx

Now the issue is that I don't know how to setup the syntax for the KERNEL_SRC variable on a Yocto recipe.

I have tried this

KERNEL_SRC ?= "git://git@192.168.30.58/home/git/linux-imx;protocol=ssh;branch=${SRCBRANCH}"

and this

KERNEL_SRC ?= "git://192.168.30.58/home/git/linux-imx;protocol=ssh;branch=${SRCBRANCH}"

But I get the following errors

Permission denied, please try again.
Permission denied, please try again.
bherrera@192.168.30.58: Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I also have the RSA public key setup on my system. It doesn't ask for the password when using SSH. I ran this command to copy my RSA key to the local git server that I have setup.

 ssh-copy-id git@192.168.30.58

Solution

  • This is the syntax that worked for me.

    KERNEL_SRC ?= "git://git@192.168.30.58:/home/git/linux-imx;protocol=ssh;branch=${SRCBRANCH}"
    

    You need to generate an RSA key. To generate your RSA key, first run this command on the client side. (Do not add a passphrase otherwise fetching will fail in Yocto).

    ssh-keygen -t rsa -b 4096
    

    Add a the following to your ~/.ssh/config file. This defaults the connections to use the generated key.

    Host 192.168.30.58
            User git
            IdentityFile /home/user/.ssh/id_rsa
    

    Lastly, copy your public key to your Git server by running the following command.

    ssh-copy-id git@192.168.30.58