If you see the error 'Cannot perform an interactive login from a non-TTY device', it means you're trying to log in interactively in an environment that doesn’t have access to a terminal (like a script or automation).
Here’s how to fix it:
-
Use Non-Interactive Methods:
Instead of aws sso login, configure AWS credentials using:
aws configure
-
This way, you avoid needing an interactive login.
-
Force a TTY:
If using ssh, add the -t flag:
ssh -t user@hostname
-
Running in Docker:
Run the container with:
docker run -it <container-name>
-
The -it flag makes the container interactive.
-
For CI/CD Pipelines: Use environment variables for credentials, since CI systems don’t support interactive logins.
-
Avoid Interaction: Pre-configure logins and avoid prompts where possible to work smoothly in non-TTY environments.