With 2FA enabled on your Docker Hub account, you'll find you cannot access it with your user password from within the CLI. Jack Wallen shows you how to make this work.
If you've recently added two-factor authentication (2FA) to your Docker Hub account, you've more than likely run into a situation where you can no longer access the account from the command line using the standard username/password credentials. Although this might be a bit of a headache, it's one you'll want to work through. Why? Because in this day and age you need as much security as you can get.
So instead of either ignoring 2FA on your Docker Hub account, or disabling it the second you can't gain access from the CLI, let's fix that problem.
SEE: Mastermind con man behind Catch Me If You Can talks cybersecurity (TechRepublic download)
What you'll need
The only things you'll need to make this work are:
A Docker Hub account with 2FA enabled
A desktop client that allows you to access Docker Hub from the CLI
A Docker Hub access token
I'll show you how to obtain the access token, but you'll need to have the other bits in place.
How to get your Docker Hub access token
The first thing to do is to get your Docker Hub access token. To do that log into your Docker Hub account. Click on your profile image in the upper right corner and select Account Settings (Figure A).
From within Account Settings, click Security in the left sidebar (Figure B).
Under Access Tokens, click New Access Token (Figure C).
In the resulting window (Figure D), give the token a name and click Create.
Finally, you'll be presented with your token (Figure E). Copy and save that token in a safe location. Once you dismiss this token you cannot retrieve it as it is not stored. Click Copy And Close and the token will be copied to your desktop clipboard.
How to log in to Docker Hub
On the system, you'll be logging in to Docker Hub, open a terminal window and issue the command:
docker login --username NAME
Where NAME is your Docker Hub username.
When prompted for a password, paste your access token and hit Enter. If you try to use your Docker Hub user password, the login will fail. With your access token the login will succeed and you're ready to start working.
Congratulations, you now can access your Docker Hub 2FA-enabled account from the command line. Enjoy that added layer of security.
- How to become a cybersecurity pro: A cheat sheet (TechRepublic)
- Windows 10 security: A guide for business leaders (TechRepublic Premium)
- How to use Docker Compose files without the docker-compose command (TechRepublic)
- How to scan your Docker installment with docker-bench-test (TechRepublic)
- How to deploy the Netbox network documentation/management tool with Docker (TechRepublic)
- How to use Docker .env file (TechRepublic)
- This cryptocurrency-stealing malware just got a significant upgrade and new tactics (ZDNet)
- All the VPN terms you need to know (CNET)
- Cybersecurity and cyberwar: More must-read coverage (TechRepublic on Flipboard)