Using passwords to login to SSH is insecure and not recommended, especially as the root user. This is why Sail uses SSH keys exclusively.
When provisioning a server with sail, a new SSH key is generated
automatically, and placed in the
.sail directory along with its public key.
This key is used automatically for any interactions done through the Sail CLI.
If you'd like to add your own SSH keys to your Sail server, you can do so using the ssh key add command.
To open an SSH shell to your WordPress server, run:
By default, this will open a shell as the
www-data user on your server, and
change to your WordPress project directory, so you could run WP-CLI and other
If you'd rather login as root, add the
sail ssh --root
And remember, with great power comes great responsibility.
To run a single command and exit, use:
sail ssh run <command>
The output and return-code of the executed command will be passed through, so it is safe to use this command in shell scripts.
We do not recommend using
wp ssh to run WP-CLI commands, since there's a more
convenient way of doing it with Sail:
sail wp <command>
If you're having trouble with SSH or WP-CLI in Sail, please refer to our getting help section.