LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 08-05-2014, 05:46 AM   #1
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Rep: Reputation: Disabled
Can't connect to SSH please help


Yesterday I changed the default ports on the server to 1993 then restarted but now I can't connect at all.

I used
Code:
ssh -i keyname.pem ubuntu@remotehost
to connect then
Code:
sudo vi /etc/ssh/sshd_config
to change the ports. After that I restarted the server using
Code:
sudo service ssh restart
Now I can't connect at all, if I try
Code:
ssh -i keyname.pem ubuntu@remotehost
then I get this:

Quote:
ssh: connect to host 12.34.5.678 port 22: Connection refused
if I try this
Code:
ssh -i keyname.pem -p 1993 ubuntu@remotehost
then I get this:

Quote:
ssh: connect to host 12.34.5.678 port 1993: Operation timed out
I've tried
Code:
ssh -v user@host
and that gives me this:

Quote:
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /Users/macuser/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 12.34.5.678 [12.34.5.678] port 22.
debug1: connect to address 12.34.5.678 port 22: Connection refused
ssh: connect to host 12.34.5.678 port 22: Connection refused
I've also tried to connect using FileZilla and all I get with that is:

Quote:
Status: Connecting to internal.livesite.com...
Response: fzSftp started
Command: keyfile "/Users/macuser/Desktop/secure_key"
Command: open "ubuntu@ remotehost" 22
Error: Connection refused
Error: Could not connect to server
If I just try to connect, but if I change the port to 1993 I get this:

Quote:
Status: Connecting to internal.livesite.com:1993...
Response: fzSftp started
Command: keyfile "/Users/macuser/Desktop/secure_key"
Command: open "ubuntu@ remotehost" 1993
Error: Connection timed out
Error: Could not connect to server
I'm desperate to get this sorted as my boss wants to go through everything with me and I can't upload any changes until this is done.

Thank you in advance for any help.
 
Old 08-05-2014, 06:10 AM   #2
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
What is your linux distribution.
Have you defined this new port in IP tables (opened in firewall)?
 
Old 08-05-2014, 06:13 AM   #3
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fortran View Post
What is your linux distribution.
Have you defined this new port in IP tables (opened in firewall)?
I'm sorry I don't understand what you mean?

I tried using sudo iptables-save but I got this:

sudo: iptables-save: command not found

and ufw allow 1993/tcpa gave this error:

-bash: ufw: command not found

Last edited by Noobie1212; 08-05-2014 at 06:17 AM.
 
Old 08-05-2014, 06:56 AM   #4
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
TRY
Code:
ssh -i keyname.pem -oPort=1993 ubuntu@remotehost

Last edited by fortran; 08-05-2014 at 07:01 AM.
 
Old 08-05-2014, 07:06 AM   #5
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fortran View Post
TRY
Code:
ssh -i keyname.pem -oPort=1993 ubuntu@remotehost
I tried that, but after a little while I got this: ssh: connect to host 12.34.5.678 port 1993: Operation timed out
 
Old 08-05-2014, 07:08 AM   #6
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Are you able to connect successfully to remote host if port is 22?

Last edited by fortran; 08-05-2014 at 07:16 AM.
 
Old 08-05-2014, 07:14 AM   #7
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fortran View Post
Are you able to connect successfully to remote host if port is 22?
No if I try to connect using port 22 I get this:
ssh: connect to host 12.34.5.678 port 22: Connection refused

I also tried using sudo ufw allow 1993 but after entering my password (I presumed it was the password of my computer) I got this:
sudo: ufw: command not found

I restarted the ssh after by using sudo service ssh restart and it's been since then that I've not been able to connect

Last edited by Noobie1212; 08-05-2014 at 07:15 AM.
 
Old 08-05-2014, 07:14 AM   #8
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,307
Blog Entries: 2

Rep: Reputation: Disabled
Does the SSH server have a firewall running on it?
How do you manage your firewall?
Did you open port 1993 (which wouldn't be open by default on a SSH server)?

You're not even reaching the point where you try to connect and fail (those are the "connection refused" messages), so for now your pki and connect string isn't important. You're timing out on the attempt to connect, which suggests firewall issues.
 
Old 08-05-2014, 07:17 AM   #9
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
Is it your LAN IP?
Check if you are able to ping it or not
Quote:
ping -c 4 12.34.5.678
If you are not able to ping it, you can't connect to it.
Check the firewall status on server, not on the client.
Quote:
service ufw status
 
Old 08-05-2014, 07:18 AM   #10
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fortran View Post
Are you able to connect successfully to remote host if port is 22?
Is it your LAN IP?
Check if you are able to ping it or not

If you are not able to ping it, you can't connect to it.
The IP is of the site I'm working on, but it's a secure internet so I can't put the real IP address down. I tried to ping it and this is what I got:

PING 12.34.5.678 (12.34.5.678): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

Before I restarted the server I was able to connect, I don't know if that's any help?
 
Old 08-05-2014, 07:19 AM   #11
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fortran View Post
service ufw status
Check the firewall status on server, not on the client.
I tried that on the terminal and it said this: -bash: service: command not found
 
Old 08-05-2014, 07:21 AM   #12
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by dijetlo View Post
Does the SSH server have a firewall running on it?
How do you manage your firewall?
Did you open port 1993 (which wouldn't be open by default on a SSH server)?

You're not even reaching the point where you try to connect and fail (those are the "connection refused" messages), so for now your pki and connect string isn't important. You're timing out on the attempt to connect, which suggests firewall issues.
The server was set up by somebody else, I'm new in the job so don't know how they managed the firewall. I only went to the sshd_config and changed the port to 1993, I didn't know I needed to open it as well. Is it too late or is there anything I can do?
 
Old 08-05-2014, 07:26 AM   #13
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
If you are confirmed that there is no firewall configured on the server then I think port is already opened.
If you are making connection in LAN and you can't make connections outside LAN, it means the server is not in same network.
Put it in same network, check network connection on server. Make sure it is enabled. Now try to connect again.
 
Old 08-05-2014, 07:28 AM   #14
Noobie1212
LQ Newbie
 
Registered: Aug 2014
Posts: 25

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by fortran View Post
If you are confirmed that there is no firewall configured on the server then I think port is already opened.
If you are making connection in LAN and you can't make connections outside LAN, it means the server is not in same network.
Put it in same network, check network connection on server. Make sure it is enabled. Now try to connect again.
I'm sorry to be so dumb but I've never worked with SSH before so am very new to everything. How do I check the firewall? I never had problems connecting before I changed the port so I'm not sure if being on the same network or not is an issue. Although if it is how do I move it?

The site is currently hosted using AWS if that makes a difference?
 
Old 08-05-2014, 07:31 AM   #15
fortran
Member
 
Registered: Nov 2011
Location: Cairo, Egypt
Distribution: CentOS, RHEL, Fedora
Posts: 300
Blog Entries: 2

Rep: Reputation: 51
If a site is hosted on the server, it means port 80 or 443 should be opened there (default http or https ports)
Can you open the website installed on server in browser from your system?
 
  


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
Initiate ssh tunnel to connect to ssh? brianmcgee Linux - Security 2 09-07-2011 11:07 AM
Able to connect via SSH but not able to connect via web port 80 Orange Sunshine Linux - Server 9 04-03-2010 08:11 PM
iptables help! DROP ssh port, but allow to connect to ssh if from 2222 port kandzha Linux - Networking 4 09-13-2006 10:10 AM
ssh + pop3 with kmail: Could not connect to host localhost, but ok without ssh Emmanuel_uk Linux - Networking 0 07-20-2006 05:56 PM
Can't connect via ssh _TK_ Linux - Networking 3 04-27-2001 07:16 PM


All times are GMT -5. The time now is 10:41 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