How I connect by ssh after configure my vps droplet?

Posted March 16, 2021 225 views
Linux BasicsSecurityDigitalOcean

Hello, I create and change the configuration of one user diferent of root, for permissions is like a root.
and i create the public key and paste into a ’/home/<newuser>/.ssh/authorized_keys’ file,
I do that exactly:

ssh <newuser>@

sudo mkdir .ssh
sudo chmod 0700 .ssh
sudo touch .ssh/authorizedkeys
sudo chmod 0644 .ssh/authorized
sudo chown <newuser> ~/.ssh -R
sudo nano .ssh/authorized_keys // i paste the pub key here a goout

// saving file
sudo nano /etc/ssh/sshd.config

// in this file I put that
Port 222
PubKeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
PermitEmptyPasswords no
PermitRootLogin yes // by the moment

// I go out saving file

sudo systemctl restart sshd.service // restart service

// now in my local ubuntu

ssh -p 222 <newuser>@

// the response from server is that:
debug1: connect to address port 222: Resource temporarily unavailable
// its the same that i treat to connect whit root

ssh -p 222 root@

you can help me what´s happend?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

I could suggest a couple of things:

  • I would set the permissions to 600 rather than 644 for extra security:
sudo chmod 0600 .ssh/authorized_keys
  • Also if you have a firewall like ufw, make sure to open port 222, as the error that you are getting indicates that your local PC is unable to connect to the Droplet on that port.

  • You can add the -vvv argument to your SSH command for some extra debug information:

ssh -vvv -p 222 <newuser>@

Let me know how it goes!