How to log in to snapcraft with only 1 command

i use snap login testtest but not work
how can snap login with user and password

You can’t. What are you trying to do?

i try to after build snap to auto snapcraft release

I think you’re wanting to ask about snapcraft login, not snap login, then.

If you want to give permission for a continuous integration system to publish snaps on your behalf, log in locally with snapcraft login, then use the snapcraft export-login command to create a data file representing your credentials.

Store that data in whatever secret storage mechanism your CI system uses (e.g. environment variables or encrypted files checked into your repository), and have the CI system run snapcraft login --with-file=path-to-exported-login-data.

When exporting your login data you can also place some conditions on the exported credentials via the --snaps, --channels, and --expires arguments. If the CI system should only be able to publish one particular snap you own to the edge channel, then you can ensure the exported credentials won’t let it do anything but that. Similarly, you can set expiration dates to limit the damage should they be leaked.


You can use snapcraft export-login and then on the host you need the credentials snapcraft login --with <exported-login>

If you are using Travis, vendor specific documentation exists at

CircleCI specific documentation also exists on but is being reworked on

1 Like

@jamesh I’m pretty sure I know the answer, but wanted to double check. If the account you use has 2fa enabled, presumably you can still generate valid macaroons and they are then used without any interaction with 2fa at all ? They are basically a Token right ?


This is correct; 2FA is only verified when checking the credentials, after which the serialized mcaaroon(s) snapcraft exports will work mostly as a bearer token.

  • Daniel
1 Like

Thanks @roadmr