LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-22-2015, 01:55 PM   #1
blackhawk2165
LQ Newbie
 
Registered: Jan 2015
Posts: 13

Rep: Reputation: Disabled
SSH and Opening Ports


Hello,

I am trying to set up SSH on my linux machine. I have all the ssh packages downloaded and have added rules to my iptables i.e.

-A INPUT -p tcp -m tcp --dport 62222 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

I also saved all the rules in a file so I could restore the iptables when I reboot the machine.

I also checked to make sure that the ports were open on the network firewall.

So I'm not sure what to do now because everywhere I look it says that once I've added those rules it should work.

Please Help!
 
Old 01-22-2015, 02:30 PM   #2
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by blackhawk2165 View Post
Hello,

I am trying to set up SSH on my linux machine. I have all the ssh packages downloaded and have added rules to my iptables i.e.

-A INPUT -p tcp -m tcp --dport 62222 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

I also saved all the rules in a file so I could restore the iptables when I reboot the machine.

I also checked to make sure that the ports were open on the network firewall.

So I'm not sure what to do now because everywhere I look it says that once I've added those rules it should work.

Please Help!
Have you checked if ssh is actually running? Which distro are you using? I am asking because the command to check whether ssh is running depends on your system's init system.
On debian it would be
Code:
service ssh status
Also please post your whole iptables script. If you are restricting the OUTPUT chain you also need to create rules to allow the ssh server to answer your requests.

If you have changed your ssh server config please also post that. Probably located at /etc/ssh/sshd_config but that also depends on your system. (Which ssh server are you running? Open-ssh, dropbear...?)

Can you actually ping the target machine from the client machine?

Last not least: Post the commands that you are running when you try to connect, and post the output! (Error messages etc.) Do not only say "it does not work" but describe what exactly does not work.
 
Old 01-22-2015, 02:40 PM   #3
blackhawk2165
LQ Newbie
 
Registered: Jan 2015
Posts: 13

Original Poster
Rep: Reputation: Disabled
Okay so when I run
service ssh status

It says:
ssh: unrecognized service

The whole iptables is too long to post and so are all the rules.

I have ubuntu server 14.04 installed.

I haven't changed my ssh_config file.
 
Old 01-22-2015, 02:42 PM   #4
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by blackhawk2165 View Post
Okay so when I run
service ssh status

It says:
ssh: unrecognized service

The whole iptables is too long to post and so are all the rules.

I have ubuntu server 14.04 installed.

I haven't changed my ssh_config file.
Ok, Ubuntu uses Upstart, so the command is probably different. Give me a minute I'll go check.
 
Old 01-22-2015, 02:47 PM   #5
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Can you post the output of the following two commands

Code:
status ssh
And

Code:
dpkg --get-selections openssh-server
 
Old 01-22-2015, 02:49 PM   #6
blackhawk2165
LQ Newbie
 
Registered: Jan 2015
Posts: 13

Original Poster
Rep: Reputation: Disabled
for the first one I got status: Unknown job: ssh

and for the second one there was no output
 
Old 01-22-2015, 02:51 PM   #7
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by blackhawk2165 View Post
for the first one I got status: Unknown job: ssh

and for the second one there was no output
Ok, that means you haven't installed an ssh server. (Maybe only the client?)

Try running
Code:
sudo apt-get install openssh-server
Then retry connecting. If it still does not work please post command and output from the client.
 
Old 01-22-2015, 02:56 PM   #8
blackhawk2165
LQ Newbie
 
Registered: Jan 2015
Posts: 13

Original Poster
Rep: Reputation: Disabled
Okay it worked. Thank you I don't know how I missed that haha
 
Old 01-22-2015, 02:58 PM   #9
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Arch, Debian
Posts: 859

Rep: Reputation: 245Reputation: 245Reputation: 245
Quote:
Originally Posted by blackhawk2165 View Post
Okay it worked. Thank you I don't know how I missed that haha
Glad it's working - have fun!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
opening ports snooze1 Linux - Newbie 8 01-25-2012 07:23 PM
Problem opening ports - ports appear open, but do not work. computer_freak_8 Linux - Software 10 09-20-2008 10:39 PM
Opening ports? skumaryermal Linux - Newbie 1 09-28-2006 02:36 PM
Opening Ports Astral_Nomad Mandriva 4 12-09-2005 01:17 PM
Ports still not opening! Help? spam4scott Linux - Networking 1 05-28-2004 01:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration