Getting started with the CLI
Installation
See the installation guide for instructions on how to install the mittwald CLI on your system.
Authenticating
API access
To use the CLI, you first need to authenticate your client using an API token. Have a look at the "Obtaining an API token" section of the introduction for details on how to obtain an API token.
Having a token, you can authenticate like this:
$ mw login token
Enter your mStudio API token: ********
For non-interactive usage (for example in CI/CD pipelines), you can also pass the token via the MITTWALD_API_TOKEN
environment variable:
$ export MITTWALD_API_TOKEN=********
$ mw login status
SSH
A few commands (like mw [app|project] download
, mw [app|project] ssh
and some of the subcomands for mw database
) connect to your actual hosting environment via SSH. For these commands, your local environment needs to be set up with an SSH keypair to authenticate against the remote server without prompting for your password.
- If you already have an existing SSH private key, you can import the public key to your mStudio account with the following command:
$ mw user ssh-key import
- To create and import a new SSH keypair, you can use the following command:
$ mw user ssh-key create
Usually, the key pair should be used automatically by the CLI. To explicitly specify the key pair to use (for example, if you receive a too many authentication failures
error), you have a few options:
- All commands that require an SSH connection respect your systems SSH configuration (typically in
~/.ssh/config
). You can specify the key to use for a specific host like this:
Host *.project.host
IdentityFile ~/.ssh/mstudio-cli
- Alternatively, all commands that require an SSH connection accept a
--ssh-identity-file
flag that you can use to specify the key to use:
$ mw app download ... --ssh-identity-file="~/.ssh/mstudio-cli"
- Instead of the
--ssh-identity-file
flag, you can also set theMITTWALD_SSH_IDENTITY_FILE
environment variable to specify the key to use:
$ export MITTWALD_SSH_IDENTITY_FILE=~/.ssh/mstudio-cli
$ mw app download ...
You can also set the MITTWALD_SSH_IDENTITY_FILE
environment variable in your shell profile (~/.zshrc
or ~/.bashrc
) to make it available in every shell session:
$ echo 'export MITTWALD_SSH_IDENTITY_FILE=~/.ssh/mstudio-cli' >> ~/.zshrc