Just created a new droplet using the one-click LAMP image.
When finished, tried to access via ssh from my stored ssh keys but only got “Permission Denied”
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.
Hi @fgastelum,
This sounds strange. Are you sure you are trying to access the droplet with your root user rather than someone else? One other thought I had in mind is if you have changed your SSH key recently?
If the above is correct, I’ll recommend connecting to your droplet via the console from your control panel and investigating the issue. You can first check out in your /var/log/secure
to see what does it say. After that, you can start debugging.
My first action would be t re-add my public key to the
~/.ssh/authorized_keys
file and see if that would help.
rwx------
and rwxr-xr-x
are fine, but rwxrwx---
is no good, even if you are the only user in your group (if you prefer numeric modes: 700 or 755, not 775). ~/.ssh or authorized_keys
is a symbolic link, the canonical path (with symbolic links expanded) is checked./.ssh/authorized_keys
file (on the remote machine) must be readable (at least 400), but you’ll need it to be also writable (600) if you will add any more keys to it.Now that we’ve passed the standard stuff, let’s get going on the more interesting stuff.
When you run
/usr/sbin/sshd -d -p 2222
On your droplet, you can then connect without a password, what does the debug information says on your droplet, It should state something like
Authentication allowed
In this case, what you can do is temporarily stop the SSH daemon and replace it with one in debug mode. Don’t worry, stopping the SSH daemon won’t kill any existing connections. This means it’s possible to run this without being connected to the droplet’s Console but it’s somewhat risky. If the connection does get broken for any kind of reason, you’ll need to connect using your droplet’s console. Anyway, you can run the following
service ssh stop
/usr/sbin/sshd -d
#...debug output...
service ssh start
If it again runs with the debug mode being on, then for sure it’s the SELinux causing the issues, it’s most probably set to Enforcing. The .ssh dir will probably be mislabeled. Look at /var/log/audit/audit.log
. Check with ls -laZ and then Run restorecon -r -v /path/to/users/.ssh
.
Regards, KDSys
Click below to sign up and get $100 of credit to try our products over 60 days!