M
M
Mike2019-05-31 19:38:25
linux
Mike, 2019-05-31 19:38:25

Why can't I connect to DigitalOcean via ssh?

Registered on DigitalOcean, created a droplet. I'm trying to connect via ssh but it doesn't work. There are private and public keys. I did it on the local machine ssh-keygen -t rsa. Two files were created in the folder /home/mikefromru/.ssh1) id_rsa 2) id_rsa.pub.
I copied the contents of id_rsa.pub and pasted it into the public key field on DigitalOcean.
5cf155bd611e1557355474.png
On the local computer I do:
ssh -i ~/.ssh/id_rsa [email protected]_ip_on_digital_ocean# try to transfer the private key.
Nothing happens, the usual new line in the terminal.
Execute ssh-copy-id [email protected]_ip_on_digital_ocean# nothing happens
Execute ssh [email protected]_ip_on_digital_ocean# nothing happens.
Through the console on DigitalOcean itself, using the usual password sent to email, it turns out to log in.
How to connect via ssh? what did/do I do wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-05-31
@google_online

Above the field for inserting a key, it says that this will not add the key to existing droplets.
There is also a link on how to add to existing ones.
You can do it yourself. Log in with a password, /rootcreate a folder .sshwith permissions in the folder 700. In it, create a file authorized_keysin which to insert the text of the public key and

mkdir -p /root/.ssh
chmod 700 /root/.ssh
echo "ваш пуб.ключ тут" >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

After that, you should be able to log in.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question