5

Is it possible to check if authorization authentication with keys is available without permission to read ssdh_config ?

3
  • I just wanted to know if it's possible without password (actually, I was not aware about the DSA keys at the moment of asking this question). Thank for your input anyway :)
    – Wiktor
    May 10, 2013 at 14:02
  • Would you mind rephrasing your question? It's not entirely clear that you weren't asking about RSA at all. I'd completely remove that reference. I can do it if you like. LMK.
    – slm
    May 10, 2013 at 14:03
  • Sure thing. Done.
    – Wiktor
    May 10, 2013 at 14:05

2 Answers 2

8

You can connect to the server allowing only public keys (and exiting immediately) with this command:

user@box ~ $ ssh -o PasswordAuthentication=no  -o BatchMode=yes HOSTNAME exit &>/dev/null
user@box ~ $ test $? = 0 && echo can connect || echo cannot connect
can connect
user@box ~ $ 

After the main command, you can check the result code to see if you can connect without password or not.

1
  • 1
    This does not work if a password is required. Will say "cannot connect" despite being able to connect. Jun 23, 2021 at 17:22
5

If the server is running and reachable:

ssh -vvv user@host

results in such lines:

Authentications that can continue: publickey
Next authentication method: publickey

Edit 1

Or limit it to the relevant output:

ssh -vvv user@host 2>&1 | grep "Next authentication method:"
3
  • 1
    I'm afraid there is no such line. Just: debug1: Host '***' is known and matches the RSA host key. debug1: Found key in /home/wiktor/.ssh/known_hosts:1 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: password debug1: Next authentication method: password
    – Wiktor
    May 10, 2013 at 13:17
  • 1
    Did you tried with -vvv? it is better to update this kind of information in the question, so it is easier to read and easier to find
    – RSFalcon7
    May 10, 2013 at 13:53
  • @RSFalcon7: yes, I have. I think this option is just off on this server. I only get info about password authentication.
    – Wiktor
    May 10, 2013 at 14:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .