SSH connection refused

Discussion in 'Mac Basics and Help' started by adjplante, Dec 30, 2012.

  1. macrumors newbie

    Joined:
    Dec 30, 2012
    Location:
    Laval
    #1
    Hi,

    I use Mac OS X version 10.7.5 and my software is up to date.

    Here is my problem: I tried to set ssh on my iMac. I am pretty sure that I am doing it OK since I have done this on my MacBook Pro, my girlfriend's iMac and it works fine there. But on my iMac when I type the same command in X11, that is:

    ssh localhost

    I get the following error:

    ssh: connect to host localhost port 22: Connection refused

    No matter what I do:
    ssh andre@192.168.2.18
    ssh andre@localhost
    I always get the same error message.

    Looks like ssh is working based on the (connect to host localhost port 22) of the error message but, on the other hand, I get the same message even if I turn off ssh by unchecking the Remote Login check box.

    Any idea?

    Thanks

    André
     
  2. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #2
    Try getting more information about what is going wrong by entering

    Code:
    ssh -vvv localhost
     
  3. thread starter macrumors newbie

    Joined:
    Dec 30, 2012
    Location:
    Laval
    #3
    Thanks for the reply LPZ :)

    Here is the result

    iMac-de-Andre:~ andre$ ssh -vvv localhost
    OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
    debug1: Reading configuration data /etc/ssh_config
    debug1: Applying options for *
    debug2: ssh_connect: needpriv 0
    debug1: Connecting to localhost [::1] port 22.
    debug1: connect to address ::1 port 22: Connection refused
    debug1: Connecting to localhost [127.0.0.1] port 22.
    debug1: connect to address 127.0.0.1 port 22: Connection refused
    debug1: Connecting to localhost [fe80::1%lo0] port 22.
    debug1: connect to address fe80::1%lo0 port 22: Connection refused
    ssh: connect to host localhost port 22: Connection refused​

    I compared my /etc/ssh_config to the one on my MacBook Pro (on which ssh is working fine) and they are the same.
     
  4. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #4
    I assume you have enabled Remote Login in the Sharing preference pane. What happens if you disable Remote Login and try

    Code:
    ssh -vvv localhost
    again? Do you get exactly the same output as above?
     
  5. thread starter macrumors newbie

    Joined:
    Dec 30, 2012
    Location:
    Laval
    #5
    Yes I have enabled Remote Login. If I disable it and run the ssh command I get the same error message. Looks like the enabling does not do its job!
     
  6. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #6
    Let's try enabling it manually. Open Terminal (in Utilities) and enter

    Code:
    sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist
    (Supply your password when it is requested) and then

    Code:
    sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
    Then try

    Code:
    ssh -v localhost
    If this still fails to work, please enter

    Code:
    sudo launchctl list | grep "sshd"
    If the ssh daemon was started in response to the ssh request (as it should have been) then you should see an output like

    Code:
    46427	-	com.openssh.sshd
    (the number may be different).
     
  7. thread starter macrumors newbie

    Joined:
    Dec 30, 2012
    Location:
    Laval
    #7
    I did all the above and it still does not work, but I get a funny process number -

    Code:
    -       0       com.openssh.sshd
     
  8. LPZ
    macrumors 65816

    Joined:
    Jul 11, 2006
    #8
    That indicates that sshd was invoked and exited normally. So now the question is: Why is sshd not allowing the connection?

    Have you modified /etc/sshd_config (the sshd configuration file) at all?

    Perhaps someone who knows more about sshd can join in.
     

Share This Page