E1Tips Qucik Tip

How to Use the CMDKEY Command to Manage Stored Credentials on Windows

The cmdkey command is a Windows utility that lets you create, delete, and manage stored credentials for network authentication. This is particularly useful for automating logins to remote servers or systems where credentials need to be stored securely. In this post, we’ll explore how to use cmdkey to manage credentials efficiently and safely.

Viewing Stored Credentials

To see the credentials stored on your system, use:

cmdkey /list

This command displays a list of all stored credentials, including the targets they’re associated with, similar to the following:

Target: Domain:target=TERMSRV/127.0.0.1
Type: Domain Password
User: user@domain.local
Local machine persistence

Target: LegacyGeneric:target=git:https://gitlab.com
Type: Generic
User: username
Local machine persistence

Adding New Credentials

You can create a new stored credential using the /add option. For example, the command below can be used to store credentials for a network share. Those credentials will be securely stored and automatically used when accessing the target.

cmdkey /add:SERVER /user:username /pass:password

Deleting Stored Credentials

To delete a specific stored credential, use the /delete option:

cmdkey /delete:SERVER

Why Use Stored Credentials?

One of the most valuable uses of the cmdkey command is to avoid storing usernames and passwords as plain text in scripts when automating repetitive tasks. For instance, you can add credentials for a remote server before configuring and running a scheduled task that uses those credentials. That way, you don’t have to store the credentials in plain text within your script.

The cmdkey command is a valuable utility for managing stored credentials, especially when working with network resources. By using options like /add, /list, and /delete, you can securely store and manage authentication details for remote systems. Integrate it into your workflow to streamline tasks that require credentials, but always prioritize security.

Author

Stewart Schatz

Career: Principal CNC Consultant for Syntax Systems Limited specializing Oracle JD Edwards EnterpriseOne and the technology that supports it. Side Hustle: Owner/Operator of E1Tips.com Location: Lancaster, PA USA  What I like to do: Invest in Family, Explore Technology, Lead Teams, Share Knowledge/Experience, Hunt, Hike, etc.

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

E1Tips Qucik Tip Previous post How to Use the XCOPY Command in Windows
Quick_Tip_Linux Next post How to Use the rsync Command to Sync Files and Directories on Linux