Sls login : how to login without browser?

I follow this doc to try the test capability of the serverless framework :
https://github.com/serverless/enterprise/blob/master/docs/testing.md

The framework is installed on an EC2 instance. My environment is the following one :

Your Environment Information ---------------------------
Operating System: linux
Node Version: 12.6.0
Serverless Version: 1.48.3
Enterprise Plugin Version: 1.3.2
Platform SDK Version: 2.0.4

The command “sls test” gives the following output :

Serverless: Run “serverless” to configure your service for testing.

So, I run the “serverless” command, that gives me the following output :

You can monitor, troubleshoot, and test your new service with a free Serverless account.

Serverless: Would you like to enable this? Yes

You are not logged in or you do not have a Serverless account.

Serverless: Do you want to register? No
If you have a Serverless account you can run “serverless login” to
login and then run “serverless” again to finish setup.

I already have a serverless account, so I run the command “sls login”, that gives me the following output :

Serverless: Logging you in via your default browser…

The problem is that I am on a EC2 instance, and there is no browser for opening the login page.
But, on the github link, there are screenshots that suggest that it can be done only using the CLI.

How can I login just using the CLI ?
If it is not possible, how can I login from an EC2 instance ?

Regards.

2 Likes

I am having a similar problem using a Visual Studio Code Remote Dev Container and came to the forums to search for this. Hopefully someone has a solution.

same here… i am evaluating some possibilities for monitoring and it would be nice if someone could provide feedback for this problem…

i used an environment variable of SERVERLESS_ACCESS_KEY with a personal access key (https://dashboard.serverless.com/tenants/TENANT_NAME/accessKeys) and was able to deploy within our azure devops pipeline. i think this would work for you, but not 100% sure

I tried what you suggest, and what alexdebrie suggests in this post : Log into Serverless Platform on a headless system
But I still get the message “Serverless: Logging you in via your default browser…”

What I tried :

  1. create an app on my serverless account : “mysuperapp” ;
  2. create a personal access key : xxxxxxxxxxxxxxx ;
  3. add the following to my serverless.yml :
tenant: mytenantname
app: mysuperapp
[...]
environment:
  SERVERLESS_ACCESS_KEY: xxxxxxxxxxxxxxx 
  1. then I run ‘sls login’ at the same level of my serverless.yml, and get the message “Serverless: Logging you in via your default browser…”.

Is there something wrong ?

Hi Patchoulin. The environment variables that needs to be set is not in serverless.yml but in the environment where serverless deploy is run for your CI/CD system. You then will not need to run sls login

try

export SERVERLESS_ACCESS_KEY=XXXXXXXXXX

and then do sls deploy

Thank you for your help, it works! :slight_smile:

1 Like

I am having the same issue - I have set the SERVERLESS_ACCESS_KE in my CI/CD environment, yet I am still getting this error

Authentication failed. - Please contact support and provide this identifier to reference this issue

I am using my personal access key. Any ideas?

Thanks.