When I SSH into my Droplet:
ssh root@xxx.xxx.xx.xxx
I get:
no such identity: .\\.ssh\\id_rsa: No such file or directory
root@myDomain.comom: Permission denied (publickey).
But ssh -i
with path works ok.
Is there a way I can just use ssh root@xxx.xxx.xx.xxx
?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Hi there,
This usually hapens when you don’t have a default SSH key. So when you specify the path to the key file with
ssh -i
, it bypasses this issue by directly using the correct key.To make
ssh root@xxx.xxx.xx.xxx
work without specifying the key each time, you can move your SSH key file to~/.ssh/id_rsa
so that all SSH connections will default to that specific SSH key file.Or alternatively, you can configure your SSH client to automatically use the correct key file depending on the SSH hostname:
The SSH client looks for configuration settings in a file named
config
in the.ssh
directory of your user’s home folder. You can create or modify this file to specify which identity file to use for each host.Open your terminal and run the following command to edit or create the SSH configuration file:
xxx.xxx.xx.xxx
with your Droplet’s IP address and~/.ssh/your_private_key
with the path to your private SSH key that you successfully use withssh -i
.After adding the necessary configuration, save the file and exit the editor. If you are using
nano
, you can do this by pressingCtrl + X
, thenY
to confirm the changes, andEnter
to exit.It’s important to set the correct permissions for the SSH config file to ensure that it is not accessible by other users on your system:
Finally, you can try connecting again using:
If everything is configured correctly, SSH should now automatically use the specified private key, and you should not see the identity error anymore.
Let me know how it goes!
Best,
Bobby
Heya, @fingers
As Bobby mentioned, this will happen when there is no default ssh-key, you can move your key to the .ssh directory and the error should be resolved.
You can also create new ssh-key pair and then upload the key to the droplet as well.
https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/
Regards
Heya @fingers,
If you check the error you are receiving, you’ll see without using
-i
SSH is trying to get the following ssh keyno such identity: .\\.ssh\\id_rsa: No such file or directory
.WHen you give -i, what path you give for SSH to work?
Also, you can set that path in your SSH config. The config is located in
~/.ssh/config
.You can set the following so that it automatically uses the custom path you have for your sshkey