Applicable to:
- Plesk for Linux
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 user@203.0.113.2
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:
CONFIG_TEXT: PermitRootLogin without-password
- Find the line that includes
-
Apply the changes:
# service sshd reload
Comments
4 comments
So, if we have to use the SSH terminal for all critical functionality, why are we using Plesk to begin with?
I've spent well over 2 hours not being able to set this up because it just doesn't work as advertised because there is no /home/user directory created to put the key files in, nor does Plesk support user folders from what I read.
Why doesn't Plesk create a /home/user directory? Why do I need to jump through SSH terminal hoops when I purchased Plesk to eliminate that requirement? What is the point of Plesk?
You need to provide an in-Plesk solution! People know how to add key files in SSH terminal thanks to Digital Ocean's amazing tutorials, that's not the point of Plesk. The point of Plesk is to provide a graphical overlay to the terminal commends we all use to setup a user with all the features we would normally use SSH terminal to implement, am I not correct?
Did all that. still getting expecting an OPENSSH key rather than an rsa key when all the instructions tell us to generate rsa keys.
How would one do this without access to the server via SSH? For example if the server is configured to not have password protection on SSH?
Hello @Tyler,
There are several options:
1) To may contact a service provider who provides the server to do it on their side.
2) You may have console access to the server.
3) Most common case, which does not suit you: SSH access using password works.
Please sign in to leave a comment.