Outgoing SSH no longer working?

Discussion in 'MacBook Pro' started by davidwellens, Oct 11, 2016.

  1. davidwellens macrumors newbie

    davidwellens

    Joined:
    Aug 23, 2016
    Location:
    Belgium
    #1
    Not sure where to post this but I've come across something odd on my end in the past week.
    I can't SSH out to another computer any more, but when I go to another station and do it from there, it does work.

    I keep getting "port 22 connection refused".
    I ran nmap localhost and port 22 isn't open, Network Utility port scan on my computer shows more ports open than nmap did, but still no port 22. But does it even have to be for outgoing connections?
    I suppose only the target device should have its port listening?


    When I run ssh -v -v -v username@hostipaddress I can see that there's definitely a connection being made, but as soon as I enter the password, it fails. Which is odd because I'm 200% certain the password is correct. After a few tries I then get this error message (ip and username redacted):

     
  2. Janichsan macrumors 65816

    Janichsan

    Joined:
    Oct 23, 2006
  3. davidwellens thread starter macrumors newbie

    davidwellens

    Joined:
    Aug 23, 2016
    Location:
    Belgium
    #3
    No, I didn't think it would be. I've been doing SSH just fine for a while now, and the weird thing is, it still works on several machines I connect to. Yet for others, where the settings and credentials are EXACTLY the same, it doesn't. That's where I get the port 22 errors or password errors.
     
  4. Janichsan macrumors 65816

    Janichsan

    Joined:
    Oct 23, 2006
    #4
    Have you checked the firewall settings on the affected computer?
     
  5. Janichsan macrumors 65816

    Janichsan

    Joined:
    Oct 23, 2006
    #5
    Just to make sure: which connection combinations have you tried? Let's say, you have computers A, B, C and D, with A the one where you have the problems connecting to D. Do I understand you correctly that you can connect without problems from computers B and C to D? Can A connect to B and/or C?

    From your log, I get the impression that the problem is not the connection per se, but the authentication. There might be a problem with the keys that normally get stored when you connect via ssh. You might try to delete (or move if you want to keep it somewhere) the ~/.ssh folder on the affected computer. That should force the creation of new keys.
     
  6. Floris macrumors 68020

    Floris

    Joined:
    Sep 7, 2007
    Location:
    Netherlands
    #6
    Not sure if you are using an ssh client that your local machine you are using the ssh client on, needs to have anything listening on port 22.. The target computer where you use that client to connect to must run sshd and by default that port unless changed.

    Try to connect with a regular account instead of 'root', and see if the remote system you are connecting to uses port 22 or has it changed to something else.

    I think I once wrote a blog post about that.

    Additionally, if the remote box is say a ubuntu linux server it might use iptables or ufw to drop port 22, who knows, maybe the policy on that server changed.
     
  7. wegster macrumors 6502

    Joined:
    Nov 1, 2006
    #7
    This is pretty odd. Your second debug log shows you cycling through auth methods and falling back to the password prompt. Check the settings on your remote sshd.config and see if AllowUsers is set up properly, or if the box is in ~/.ssh/known_hosts?

    Doesn't seem like a firewall issue on either side considering as far as you've gotten (both sending and receiving packets) from your log.
     
  8. davidwellens, Oct 12, 2016
    Last edited: Oct 12, 2016

    davidwellens thread starter macrumors newbie

    davidwellens

    Joined:
    Aug 23, 2016
    Location:
    Belgium
    #8
    The target computer (let's say B) I fail to connect to is actually a storage medium, so I can't reverse it and see if I can connect from that to my own comp (A), let alone another (C). When I connect from my comp A to C, that works flawlessly. I also tried another computer (D) and have it connect to B, which also worked. So the problem is definitely on my end.

    The odd thing is, I've tried removing the stored keys, but it says there's nothing to remove? Let me try that again using ssh-keygen -R hostname and I'll come back here after.

    I can't connect to B using another account because 'root' is the only account available on the storage medium (A). But using root via ssh works just fine from D.
    That's what I thought too. The log at the very least clearly shows I can get to the door and insert the key. But once there it's game over :( I'll try removing the key from known_hosts and come back with the result.
    --- Post Merged, Oct 12, 2016 ---
    I've renamed the known_hosts file so there wasn't any left and a new file had to be created. I still get the
    Permission denied (publickey,keyboard-interactive) on some hosts and on others I don't. This is really weird. We're talking about user laptops that have two accounts (their own, and our support one). The support account has the same password everywhere, I can guarantee that to T, because I set up all of those accounts (and laptops) myself.

    I'm absolutely stunned as to why some computers will let me in and others won't.

    This is the log for a computer that does allow me to connect (I've changed the username to username and the IP to 12.3.45.678 for privacy reasons). I've left the hostnames. I doubt that's any useful.

    This is the log on a computer where it doesn't work; EXACT same userid AND password, mind you. Details again withheld, but it's obviously not the same IP/comp.

     

Share This Page