[SOLVED] Port 22: Connection refused!?
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Port 22: Connection refused!?

    Hey all,

    Friday night I was working on some networking stuff between my two Fedora 14 boxes. I have my laptop and my desktop. on both machines I have "system-config-firewall 1.2.27" and "iptables" (i believe both come standard on F14?) I kept getting the same message as seen below before realizing perhaps I should check my firewall!

    I added a rule for incoming and outgoing traffic on port 22 and was able to get in with no problems at all!
    however today I can't ssh into anything... I can't use "Remote Desktop Viewer 2.31.4" to vnc into the machine anymore. I can't remember the exact error message at this time, it's something close to "Connection was terminated" or "Unable to connect" I can update this message later.

    last night I foolishly uninstalled the system-config-firewall and then uninstalled iptables to see if it was a simple firewall issue.... totally hosed my system <insert smiley!>

    After reinstalling and realizing I didn't backup my documents <insert smiley!...again...> I started reinstalling all of my applications. I'm still unable to use ssh and I've tried to ssh my own computer.

    Is this possible?

    # ssh 127.0.0.1
    ssh: connect to host 127.0.0.1 port 22: Connection refused

  2. #2
    Join Date
    Mar 2004
    Location
    In your closet
    Posts
    16,051
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    Is ssh running?
    PHP Code:
    service ssh status 
    Glenn
    The Bassinator

  3. #3
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    [root@fedora micah]# service ssh status
    ssh: unrecognized service


    interesting... let me search yum for ssh

  4. #4
    Join Date
    Jul 2005
    Location
    RainCity
    Posts
    1,890
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    Type this to start it.
    Code:
    service sshd start
    Kurt Driver
    Vancouver, Canada

    https://www.wikitree.com/wiki/Driver-1479

  5. #5
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    [root@fedora micah]# yum install openssh.x86_64
    Loaded plugins: langpacks, presto, refresh-packagekit
    Adding en_US to language list
    Setting up Install Process
    Package openssh-5.5p1-24.fc14.2.x86_64 already installed and latest version
    Nothing to do
    [root@fedora micah]# yum install openssh-clients.x86_64
    Loaded plugins: langpacks, presto, refresh-packagekit
    Adding en_US to language list
    Setting up Install Process
    Package openssh-clients-5.5p1-24.fc14.2.x86_64 already installed and latest version
    Nothing to do



    Interesting as well... Thoughts?

    ---------- Post added at 09:44 AM ---------- Previous post was at 09:42 AM ----------

    [root@fedora micah]# service sshd status
    openssh-daemon is stopped
    [root@fedora micah]# service sshd start
    Generating SSH2 RSA host key: [ OK ]
    Generating SSH1 RSA host key: [ OK ]
    Generating SSH2 DSA host key: [ OK ]
    Starting sshd: [ OK ]

    You sir are a genius!! What do I need to do in order have sshd start when the computer does?

    ---------- Post added at 09:50 AM ---------- Previous post was at 09:44 AM ----------

    Disregard the last question. I'm going to mark this post as solved and go research my second question! Thanks again Kurt

  6. #6
    Join Date
    Mar 2004
    Location
    In your closet
    Posts
    16,051
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    Crap! My bad! Should have been service sshd status.

    PHP Code:
    [glenn@server ~>$ service sshd status
    openssh
    -daemon (pid  1493is running... 
    Set the daemon to on and then start it.
    PHP Code:
    chkconfig sshd on
    service sshd start 
    It will then start automatically at every boot.
    Glenn
    The Bassinator

  7. #7
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    service sshd status
    openssh-daemon (pid 1503) is running...


    perfect thank you!

  8. #8
    Join Date
    Feb 2012
    Location
    philippines
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    to the administrators, please help me about the port 22 refused/timeout for wan connection, but for lan it is working... i already closed my firewall, but still having port 22 refused/timeout problem.. is it possible that the problem is come from the internet service provider?

    please help me.. thanks and god bless

  9. #9
    Join Date
    Jan 2013
    Location
    tnk
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Re: Port 22: Connection refused!?

    rm -rf /root/.ssh/*

    service sshd stop
    service sshd start

  10. #10
    Join Date
    Aug 2010
    Location
    Al Ain, UAE
    Posts
    2,028
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    First of all, you don't really need a firewall on a Linux machine, so you can safely disable it till you got things under control.

    You say it works on the LAN. Therefore SSH is OK. You just have a firewall problem so turn it off to prove the point.

  11. #11
    Join Date
    Feb 2005
    Location
    Montreal
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    hi mehdi601f,

    To open port 22, open a terminal, switch to root and run the following command:

    iptables -A INPUT -p tcp -m tcp --syn --dport 22 -j ACCEPT

    Hit enter end exit your shell

    Two good sources for configuring and managing iptables are:

    http://wiki.centos.org/HowTos/Network/IPTables

    http://www.linuxhomenetworking.com/w...s#.URLOImeym2g

    Although I am sure that there is some sort of GUI to manage iptables, it really will help you in the long term if you learn how to manage and monitor your firewall from the command line.

    Good luck

    zog

    ---------- Post added at 05:04 PM ---------- Previous post was at 04:46 PM ----------

    btw:

    I forgot to mention, if you want to keep this port open for future use, do the following to make the changes permanent:

    iptables-save > /etc/sysconfig/iptables

    systemctl restart iptables.service

    Just remember, always start your security at "Paranoid" and RAISE your security as needed. I am not trying to be funny. Leaving ports open that do not need to be open is a bad security practice to get into.
    Last edited by zogthegreat; 6th February 2013 at 10:48 PM.

  12. #12
    Join Date
    May 2013
    Location
    India
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Port 22: Connection refused!?

    I use fedora 16. From my machine if I connect to any machine within network, it can be connected easily. After connecting the machine if I type finger, it shows my machine also, but if I want to connect my machine from that machine via ssh username@IP it shows the following error 'ssh: connect to host 172.16.22.151 port 22: Connection refused'. This problem has arose suddenly. Few days back also I can connect to my machine from any machine. But I cannot connect now. Please help me.

    service sshd status shows:
    Redirecting to /bin/systemctl status sshd.service
    sshd.service - OpenSSH server daemon
    Loaded: loaded (/lib/systemd/system/sshd.service; enabled)
    Active: failed since Wed, 29 May 2013 12:58:02 +0530; 26s ago
    Process: 2830 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
    CGroup: name=systemd:/system/sshd.service


    system-config-services part
    sshd is failed it shows:
    This unit has failed: failed
    It is not running or started or any thing else.

    system-config-firewall is enabled and there ssh is ssh is checked and port/protocol status is 22/tcp

    Please help me to solve the problem

Similar Threads

  1. SSH error: port 22 connection refused
    By snehal.lamture in forum Linux Chat
    Replies: 1
    Last Post: 22nd April 2009, 07:44 AM
  2. SSH connection refused
    By infernosoft in forum Servers & Networking
    Replies: 5
    Last Post: 9th April 2009, 12:32 PM
  3. Connection refused until in network connection
    By JJS in forum Servers & Networking
    Replies: 5
    Last Post: 2nd November 2004, 08:27 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •