Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

commandantp's avatar

Connecting the DigitalOcean droplet as root

Hi,

Not too sure how forge configures the droplet and root acces. How can I modify the sshd_config file, when logged in as forge it is in read only mode... Thanks!

0 likes
6 replies
xingfucoder's avatar

Hi @commandantp, I didn't use Forge but I think you could connect using SSH with any local console App as ConEmu and make all changes you need within your server.

You should be able to log in with the following command:

ssh -p22 youruser@Your-IP-Direction

Then, if you configured your RSA SSH Key with a paragraph password, it will require you.

commandantp's avatar

I only get permission denied (publickey), how do you know which username is being used? I gave a name say aaa to the ssh key when adding it in the user interface of Digital Ocean. So should it be aaa@123.456.123 ? Sorry I am new to that and a bit lost... edit: I am continuing here not to pollute the other post.

xingfucoder's avatar

Hi, don't worry, I'm new to server management too.

Your base user is root in DigitalOcean, and if you made use of a RSA KEY You need to link to your Dropplet in some way, using the Droplet creation link,or copying your public key to the /.ssh/authorized_keys file. If you use the first way, you don't need to put the authorized_keys content.

The you need to modify your /etc/ssh/sshd_config file and change the line of PermitRootLogin yes to no.

Finally, save your changes and restart SSH service using:

sudo services ssh restart

Then try connecting with the command I recommended you before. You may need write your paragraph password as needed (not the user default password)

By default, your key should be named as id_rsa, if I'm not wrong.

xingfucoder's avatar

Sorry, the last step of change the PermitRootLogin is not needed because you are using root user.

I try to edit this answer using Tablet size but I cannot find the buttons :( because they are not visible.

1 like
fideloper's avatar

Forge turns off the ability to access the server over SSH via root (a security precaution I suggest you keep!)

As @codeatbusiness mentions, you can change that in /etc/ssh/sshd_config via the PermitRootLogin option.

Since the root user may not have a ssh key setup for access, you may also need to allow Password-based login. Within /etc/ssh/sshd_config, set PasswordAuthentication to yes.

Then you can log into your droplet as root, using a password.

To SSH into the server without SSH attempting to use a key-pair (going right to asking for a password), use the "PubKeyAuthentication" option:

ssh -o "PubkeyAuthentication no"  root@your-server-ip

Lastly, I don't suggest doing this. At the very least, add your ssh public key to your root user's authorized_keys file so you can keep PasswordAuthentication off.

3 likes
Shovels's avatar

I've just stumbled on this when setting up a new server on Digital Ocean. As @fideloper says, root's SSH access is removed when you run the Forge installation script.

To gain access via SSH again you need to log into Forge, view your server, go to the 'SSH Keys' tab and add your SSH key.

(Your SSH key can be accessed from your terminal by running)

cat ~/.ssh/id_rsa.pub

When you SSH in now just use:

ssh forge@your-servers-ip-address
2 likes

Please or to participate in this conversation.