Question
How to set up SSH keys for Plesk server?
Answer
-
Connect to the server via SSH.
-
Create the RSA Key Pair:
# ssh-keygen -t rsa -b 2048
Use default location
/root/.ssh/id_rsa
and setup passphrase if required. -
The public key is now located in
/root/.ssh/id_rsa.pub
The private key (identification) is now located in/root/.ssh/id_rsa
file.Note: Permissions for the private key should be
0600
-
Copy the public key to another server using the
ssh-copy-id
command:# ssh-copy-id [email protected]
where
user
andIP address
should be replaced with second server's credentials.Note: in case ssh-copy-id is missing on RHEL-based system, use the following command to install required package:
# yum install openssh-clients
Alternatively, copy the content of
/root/.ssh/id_rsa.pub
to/root/.ssh/authorized_keys
on the second server.Note: permissions for the
authorized_keys
files should be set to0600
SSH Keys Manager can be used to upload public part of SSH key pair to a Plesk server.
Additional information
After successful login using the SSH key, it is possible to restrict the password-based login:
-
Open SSH server configuration file:
# vi /etc/ssh/sshd_config
- Find the line that includes
PermitRootLogin
and set it to:
PermitRootLogin without-password
- Find the line that includes
-
Apply the changes:
# service sshd reload