Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've installed Ubuntu 12.04.1 LTS on it with the LAMP stack.

I can ping it but when I try to connect to it the server can't be found.

When I try to connect with WinSCP I get the error Network error: connection refused.

I've installed the openssh-server and openssh-client packages but still can not connect.

share|improve this question
    
Please, could you try to describe better your setup? For example: is the server directly connected to the Internet? Is there a router? Is there a firewall? Thanks! –  Andrea Corbellini Jan 10 '13 at 17:47
1  
Try: sudo netstat -tlpn first. You should see something running on port 22, and it should be an ssh server. Update with the results. –  Cory Jan 10 '13 at 17:53
add comment

1 Answer 1

Sounds like a firewall issue to me. Is this machine behind a Physical Firewall on a different network or on the same LAN? If it is on a different network, check both the gateway firewall and the host firewall (iptables) and make sure that port 22 is ALLOWED.

To do this follow these instructions:

Login as the root user.

Open /etc/sysconfig/iptables file, enter:

# vi /etc/sysconfig/iptables

Find line that read as follows:

COMMIT

To open port 22 (ssh), enter (before COMMIT line):

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

Save and close the file. Restart the firewall:

# /etc/init.d/iptables restart

Next check to make sure the service is listening.

Try issuing the command:

netstat -vatn | grep :22 and see if port 22 is listening.

You could also try:

netstat -vatn | grep ssh

This will take care of the Host-Based Firewall, but if there is a Network-Based firewall between you and the machine you are trying to remote into than you will have to consult that specific devices instructions for allowing connections to port 22 into the network.

share|improve this answer
    
If the remote server is behind a hardware firewall, you'll need to change the firewall there accordingly as well. Same applies if you're behind a router, or other corporate network with IP/packet/firewall filtering. –  Thomas W. Jan 28 '13 at 21:30
    
Yeah thats what I pointed out in the last paragraph of my answer. –  Kentgrav Jan 28 '13 at 21:42
    
I only posted the note because some users don't read the entire text of answers, and wanted to make sure that point stood out. –  Thomas W. Jan 28 '13 at 21:45
    
What? /etc/sysconfig? /etc/init.d/iptables? Are you talking about RedHat/Fedora? There's no such a thing on Ubuntu/Debian! –  Eric Carvalho Jan 28 '13 at 21:47
    
Yeah thanks for pointing that out Eric. I've yet to completely understand all the differences in a Debian based Linux distro. The locations/naming conventions may be different, I work in an government/enterprise environment on mainly CentOS and RedHat so forgive me for any confusion. The basic concept is till the same. –  Kentgrav Jan 29 '13 at 16:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.