# Favorite WP-CLI Packages: Login Command

## Passwordless logins for WordPress

[wp-cli-login-command](https://github.com/aaemnnosttv/wp-cli-login-command) is a package by [Evan Mattson](https://twitter.com/aaemnnosttv) that creates **passwordless links** for your WordPress sites.

I've been adding the login command WP-CLI package on every site that I've touched since the beginning of last year. If you're a Trellis user, you can define `wp_cli_packages` in `main.yml` to have them installed on your sites:

```
wp_cli_packages:
  - aaemnnosttv/wp-cli-login-command

```

Make sure to also add the companion WordPress plugin to your Bedrock/Composer based WordPress site:

```
$ composer require aaemnnosttv/wp-cli-login-server

```

 Copy

I also install the package on my host machine for when I'm working on Valet sites:

```
$ wp package install aaemnnosttv/wp-cli-login-command

```

 Copy

After installing the WP-CLI Login Command package and activating the companion WordPress plugin, we can start diving into `wp login`:

```
usage: wp login create <user-locator> [--expires=<seconds-from-now>] [--url-only] [--launch]
   or: wp login email <user-locator> [--expires=<seconds-from-now>] [--template=<path-to-template-file>]
   or: wp login install [--activate] [--yes]
   or: wp login invalidate
   or: wp login toggle [<on|off>]
```

## Create magic login links

The simplest usage:

```
$ wp login create admin

```

 Copy

```
Success: Magic login link created!
------------------------------------------------------------
https://bedrock.test/26bf1c0a/c559d1c106-17a1dce668-69ac59ee
------------------------------------------------------------
This link will self-destruct in 15 mins, or as soon as it is used; whichever comes first.
```

Following the link will bring you directly to the WordPress admin dashboard for the user you defined ✨.

In conjunction with [WP-CLI aliases](https://roots.io/leveraging-wp-cli-aliases-in-your-wordpress-development-workflow/), the login command is even more powerful by allowing you to quickly login to any environment of a WordPress site.

Right now I'm switching between several projects that I consistently login to via `wp login`. Being able to define the environment means that I never have to leave my host terminal to get into a site:

```
$ wp @staging login create traderjoes

```

 Copy

```
Success: Magic login link created!
-------------------------------------------------------------------------
https://cookiebutter.stagingsite.link/04ed8272/ba6bec0b85-5fc03dc3-c1831b7c84
-------------------------------------------------------------------------
This link will self-destruct in 15 mins, or as soon as it is used; whichever comes first.
```

## Implementation with a Slack bot

A year ago I started heading down the path of integrating [BotMan](https://botman.io/) and the WP-CLI login command together in order to get passwordless links via Slack:

![WP-CLI login command bot](https://roots.io/app/uploads/wp-cli-login-command-bot.png)There's a lot of potential with this command and all of the ways you could go about implementing it. [Evan's plans for v2](https://github.com/aaemnnosttv/wp-cli-login-command/issues/22) include:

> - Move all core functionality to the server plugin (no interface). This should make things a bit simpler implementation-wise and the CLI will be more of a "client" for using the plugin. This will also allow for programmatic creation of logins via your own plugin 🎉
> - Move magic login data to a custom table to allow for some new features that aren't possible with the current transient-based persistence.
> - Probably rewrite a bunch of stuff.
> - GitHub Updater?
> - Punch &amp; pie.

Keep in mind that user passwords are still in place with this command and plugin out of the box, but modifying your WordPress installation to be completely passwordless isn't out of the question.

[Magic Password](https://wordpress.org/plugins/magic-password/) looks promising, but there's [not much going on](https://wordpress.org/plugins/tags/passwordless/) in [this space](https://wordpress.org/plugins/tags/one-time-password/) right now.