SSH server Permission denied (publickey)

In the past I set up an ssh server with pubkey-only authentication on a kali linux, and it worked, but now I am on Ubuntu 18.10 and it won't work. When I try to connect with client I get: Permission denied (publickey)

Usually, on kali, I'd use ssh tunneling service serveo.net with the following command successfuly:

ssh -R crayyhost:22:localhost:1337 serveo.net

And I'd connect to the server like this: ssh -J serveo.net auser@crayyhost

But here I simply can't. I cant connect to myself... The server is on ubuntu and the client is on kali.

I can't even connect with ssh auser@EXTERNAL_IP -p 1337 - I get "Connection refused".

The same goes for LAN: ssh auser@192.168.1.2 -p 1337 - "Permission denied"

The server can connect to himself with ssh localhost -p 1337, and the server can even connect to himself remotely with ssh -J serveo.net auser@crayyhost, but the client can't.

The client's id_rsa.pub file has been added to .ssh/authorized_keys

I even disabled StrictMode in sshd_config

2 Answers

"Connection refused" means there's probably a firewall in the way. Try running telnet 1337 to verify that the port is at least accessible from where you're trying to connect.

"Permission denied" for ssh auser@192.168.1.2 -p 1337 suggests that, besides a firewall, your public key isn't properly installed. if you have added the .pub key to the correct directory, maybe try restarting the ssh service to make sure it picks it up.

other than that, double check everything that's listed in the answer to this question:

1

You may need to specify your private key.

Use ssh -i <private key path> user@server -p 1337

For example if you are in the directory with your private key thats copied directly to your machine, you could use ssh -i id_rsa -p 1337. This tells it to use a private key that you have specified.

You could also research on how to add this to the config file in ~/.ssh to automate it, as well as the port.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like