Private snap download

Hi I have a private snap that I want to install on an Ubuntu Core system without logging into Snapcraft credentials. How can I install private snaps without using snap login? Is there any way to I can give access to my private snap when I am creating the Ubuntu Core image?

You can pass UBUNTU_STORE_AUTH_DATA_FILENAME="..." to ubuntu-image when creating an Ubuntu Core Image.

See this post for the technical detail and this doc for exporting your credential. You can also check snapcraft export-login --help to limit the usage of your exported credential.

I have passed my credentials through $ export SNAPCRAFT_STORE_CREDENTIALS=$(cat ) when I am creating an ubuntu core image and also I have given my credentials when I am logging into Ubuntu Core OS but I am not getting access to my private snap. tell me any other solutions

I don’t know if ubuntu-image takes the SNAPCRAFT_STORE_CREDENTIALS environment variable. I guess no, because there’s no such string in the snap program which is called by ubuntu-image to generate the content of image.

Did you try UBUNTU_STORE_AUTH_DATA_FILENAME?

Can you suggest me when I can define this like process UBUNTU_STORE_AUTH_DATA_FILENAME

You could define this environment variable before calling ubuntu-imageby using either env UBUNTU_STORE_AUTH_DATA_FILENAME="/path/to/your-creds" ubuntu-image snap ... or export UBUNTU_STORE_AUTH_DATA_FILENAME="path/to/your-creds"; ubuntu-image snap ...

whenever I am trying to create ubuntu core with above process I am getting error as "ubuntu-image snap my-model.model Error: Error preparing image: cannot decode auth file “credentials.txt”: invalid character ‘e’ looking for beginning of value "

{ “type”: “store”, “data”: { “username”: “your_snapcraft_username”, “password”: “your_snapcraft_password_or_token” } } In this format I have stored my credentials as ‘auth.json’ but when I am trying to run “export UBUNTU_STORE_AUTH_DATA_FILENAME=”/home/akshay/anand/ubuntu-core-22/new/auth.json"; ubuntu-image snap my-model.model" I am getting error as " Error: Error preparing image: invalid auth file “/home/akshay/anand/ubuntu-core-22/new/auth.json”: missing fields "

Can please tell me what was the issue

can you please provide the file format for “UBUNTU_STORE_AUTH_DATA_FILENAME” variable I am get confused how can store the credential in that file

When you run snapcraft export-login creds.auth, it will ask for your Ubuntu SSO. If the login information is correct, it will then create the creds.auth file for store authentication. The content is in base64 encoded format. This file will be readable/used by ubuntu-image.

I have no idea about the json file you put in auth.json. Probably it’s something I never used before.

As you told same way i have created creds.auth file but I am getting error “Error: Error preparing image: cannot decode auth file “/home/akx/anand/ubuntu-core-image/creds.auth”: invalid character ‘e’ looking for beginning of value” Please can you suggest me to solve this error

What versions of snapcraft, snapd and ubuntu-image are you using? The format of the authentication file has been changed since snapcraft 7.x Therefore, if you are using an old version, there could be compatibility issue. Here is the versions I am using.

$ snapcraft version
snapcraft 8.3.1
$ snap version
snap    2.64
snapd   2.64
series  16
ubuntu  22.04
kernel  6.8.0-38-generic
$ ubuntu-image --version
ubuntu-image 2.2+snap10

Here is the versions I am using it’s almost same but why I am getting error

$ snapcraft version snapcraft 8.3.1 $ snap version snap 2.63+22.04 snapd 2.63+22.04 series 16 ubuntu 22.04 kernel 6.5.0-1025-oem $ ubuntu-image --version ubuntu-image 2.2+22.04ubuntu3.22.04.1

The ubuntu-image you are using is the deb version and doesn’t support the new format of authentication file. Please use the snap version instead.

$ sudo snap install --classic ubuntu-image

P.S. I’m using the 2/stable track of ubuntu-image, but the latest/stable is 3.4.

Still I am facing same error as "Error: Error preparing image: cannot decode auth file “/home/akx/anand/ubuntu-core-image/creds.auth”: invalid character ‘e’ looking for beginning of value " Can you please provide me any alternate solutions.

If which ubuntu-image is not /snap/bin/ubuntu-image, please use absolute path /snap/bin/ubuntu-image.

Why we need to use absolute path " /snap/bin/ubuntu-image" only.

It depends on the PATH environment variable on your system. Usually /snap/bin is after /usr/bin.

Because you already have the debian version of ubuntu-image installed, it will be used as the default one, if path is not given explicitly.

I am able to create image and installed successfully but I have tried to download the private snaps again it’s same error "snap not found ". So I am not able to download private snaps after giving UBUNTU_STORE_AUTH_DATA_FILENAME environment. Can suggest me any other way or anything I have missed

What command did you use to download the private snap? Is the credential file available on the system with your image?

I thought you already have the snap included in your image. Why do you still need to download it? Or did I misunderstand your original question? :confused: