Question

ssh via Tunnel fails (publickey)

i have a strange issue, started a new droplet, everything basic with an ssh-rsa kay attached, i can log in via ssh just fine, but when i try to use a application that utilizes a ssh tunnel … Like navicat sql or a sftp client, i’m getting a pubkey or a general access denied erro. i have done this with quite alot of servers already, made sure permissions are correct, the keys are valid, sshd config is pretty much out of the box (i just disabled password auth and PAM use)


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.

alexdo
Site Moderator
Site Moderator badge
August 2, 2024
Accepted Answer

Hello,

I’ll recommend you to check the logs in /var/log/auth.log or /var/log/secure (depending on your Linux distro):

sudo tail -f /var/log/auth.log

Some commond errors can be:

  • Authentication refused: bad ownership or modes for directory - Incorrect permissions.
  • Failed publickey for user - Incorrect SSH key or user settings.

You can ensure that your SSH key permissions are set correctly on your local machine. Permissions for the SSH key must be restrictive:

Private Key: Should be readable only by your user.

chmod 600 ~/.ssh/id_rsa
  • Public Key: Usually has less restrictive permissions.
chmod 644 ~/.ssh/id_rsa.pub

SSH Directory: Should be accessible only by your user.

chmod 700 ~/.ssh

Check permissions on your server as well:

Authorized Keys: Should be readable only by the user.

chmod 600 ~/.ssh/authorized_keys

Regards

KFSys
Site Moderator
Site Moderator badge
August 2, 2024

Heya,

Are you sure that the Apps you are using are actually getting the proper key to use?

I’ve had instances where I couldn’t connect just because the APP I was using didn’t get the proper key.

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.