easy ssh question

When I SSH into my Droplet:


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

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
April 14, 2024

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 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:

  1. 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.

  2. Open your terminal and run the following command to edit or create the SSH configuration file:

    nano ~/.ssh/config
    • Add the following configuration:
          User root
          IdentityFile ~/.ssh/your_private_key
          IdentitiesOnly yes
      Replace with your Droplet’s IP address and ~/.ssh/your_private_key with the path to your private SSH key that you successfully use with ssh -i.
  3. After adding the necessary configuration, save the file and exit the editor. If you are using nano, you can do this by pressing Ctrl + X, then Y to confirm the changes, and Enter to exit.

  4. 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:

    chmod 600 ~/.ssh/config

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!



Site Moderator
Site Moderator badge
April 16, 2024

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.


Site Moderator
Site Moderator badge
April 15, 2024

Heya @fingers,

If you check the error you are receiving, you’ll see without using -i SSH is trying to get the following ssh key no 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

    User root
    IdentityFile ~/.path/to/your_private_key
    IdentitiesOnly yes

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel