This article provides a detailed guide on enabling and using SSH access through the Plesk administration tool. It describes how to log in, use SSH port 2121, and execute commands. It also lists available commands and tools such as Composer, PHP versions, and SSH keys. The article explains how to properly set up MySQL connections and offers tips for using WordPress CLI and Drupal. On Managed Servers, SSH is disabled by default and must be enabled through support.
Activation
Login / Connection Setup
Available Commands
Additional Notes
-
Activation
- Log in to the Plesk administration tool.
If you no longer have the Plesk admin password, please refer to the article: Forgot Password
- Under the menu item Websites & Domains, you can enable SSH access for the system user under Web Hosting Access:
- Now select /bin/bash (chrooted) for SSH server access:
Login / Connection Setup
Use SSH port 2121:
# ssh <username>@<server> -p2121
youruser@server.host.com's password:
user@server />Alternatively, you can connect using an SSH client such as PuTTY, iTerm, MacOS Terminal, or similar.
Available Commands
Basic Commands awk, basename, cat, cd, chgrp, chmod, chown, cp, cut, date
echo, env, expr, file, gawk, grep, hostname, less, ln, ls
mkdir, more, mv, printenv, pwd, readlink, rm, sed, sleep
sort, stat, stty, tail, timeout, touch, tput, tr, uname, uniq
wc, which, xargs, zgrep, zlessNetwork / File Transfer curl, rsync, scp, ssh, ssh-keygen, ssh-keyscan, wget Editor vi, vim, nano Compression / Archiving gunzip, gzip, tar, unzip, zip, bunzip2, bzip2 Search find, grep, diff Database mysql, mysqldump Developer Tools composer (Version 2), composer1 (Version 1), composer2 (Version 2)
git, patch, wp (WP-CLI)
PHP 7.4: /usr/bin/php or php
PHP 7.3: /opt/php73/bin/php
PHP 8.0: /opt/php80/bin/php
PHP 8.1: /opt/php81/bin/php
PHP 8.2: /opt/php82/bin/phpAdditional Notes
Here you will find further notes about SSH access.
MySQL
Composer
SSH
WordPress CLI / Drupal (drush / Drupal Console)
PHP
Customer Contributions
Managed ServersMySQL
Connection Setup
The connection to the database server must be made via 127.0.0.1. For this, access from 127.0.0.1 must first be allowed in Plesk. To do this, click in Plesk under "Databases > User Management" on the respective user and then enable the option "Allow remote connections from" under "Access Control" and enter 127.0.0.1 in the field below.
Afterwards, you can connect via shell as follows.
Example:
user@server /> mysql -h 127.0.0.1 -u <database_user> -p <database>
Composer
Composer is globally installed in versions 1.x and 2.x and can be called as follows:
$ composer
$ composer1
$ composer2Example
$ composer create-project -s dev typo3/flow-base-distribution testproject
Installing typo3/flow-base-distribution (dev-master 855c48407039a5917e4e4e35c92b841b99ab8b84)
- Installing typo3/flow-base-distribution (dev-master master)
Cloning master
Created project in testproject
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing composer/installers (v1.0.13)
Loading from cache [..]Example Composer Update with different PHP versions and increased memory_limit
/opt/php73/bin/php -d memory_limit=2048M /bin/composer update
/opt/php74/bin/php -d memory_limit=2048M /bin/composer update
/opt/php80/bin/php -d memory_limit=2048M /bin/composer update
/opt/php81/bin/php -d memory_limit=2048M /bin/composer update
/opt/php82/bin/php -d memory_limit=2048M /bin/composer updateSSH
Adding Your Own SSH Key
To connect without a password, you can add your public SSH key to the server at any time. Create a ".ssh" directory at the root level (/) and place the key in the authorized_keys file:
user@server /> mkdir ~/.ssh && chmod 700 ~/.ssh
user@server /.ssh> cd .ssh
user@server /.ssh> vi authorized_keys
user@server /.ssh> chmod 600 authorized_keyssudo
The sudo command is not required because PHP is executed directly with your own system user.
For example, your CMS documentation may list the following commands:
# sudo -u www.data php occ maintenance:mode --on
# sudo -u www.data php occ db:add-missing-indices
# sudo -u www.data php occ db:convert-filecache-bigint
# sudo -u www.data php occ maintenance:mode --offYou can run these commands directly in the shell as follows:
php occ maintenance:mode --on
php occ db:add-missing-indices
php occ db:convert-filecache-bigint
php occ maintenance:mode --offWordPress CLI / Drupal (drush / Drupal Console)
No database connection possible
When running wp commands, the following error is displayed:
Error: Error establishing a database connection
or with drush:
* connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell.By default, the application sets "localhost" as the database host. Since the shell environment works with TCP, socket access is not possible. Therefore, a configuration change is necessary. You can either change "localhost:3306" to "127.0.0.1:3306" or make the config dynamic.
Example WordPress (wp-config.php):
/** Tell WP-CLI to use TCP instead of socket connection */
if ( defined( 'WP_CLI' ) && WP_CLI ) {
/** MySQL hostname for WP-CLI */
define('DB_HOST', '127.0.0.1:3306');
} else {
/** MySQL hostname */
define('DB_HOST', 'localhost:3306'); }PHP
Changing PHP Version
By default, PHP 7.4 is used when running the "php" command. However, you can adjust this with an alias according to your needs.
Example PHP 8.0:
alias php='/opt/php80/bin/php'
echo "alias php='/opt/php80/bin/php'" >> ~/.bash_profile
export PATH=/opt/php80/bin:$PATH
echo "export PATH=/opt/php80/bin:\$PATH" >> ~/.bash_profileCustomer Contributions
Automated Deployments
- Florian Moser - plesk-deployer: https://github.com/FlorianMoser/plesk-deployer
Managed Servers
On Managed Servers, SSH is not available externally by default. Please contact support to enable SSH access.
- Log in to the Plesk administration tool.