tpmcd
Posts: 7
Joined: Mon Jul 30, 2012 4:09 pm

SSH Troubleshooting [SOLVED]

Sat Feb 13, 2016 11:17 pm

I have a Pi model 1 that I wanted to retask for a new project. I decided to load up a fresh image and begin with a clean state so earlier this week I installed the 2016-02-03 Raspian Jessie image. At this point I have made two changes:

1. I installed xrdp so I could connect using Remote Desktop from a Windows machine.
2. I edited /etc/ssh/sshd_config and changed the port to 1024 as I already had another machine using Port 22 on the network.

I am not able to make an SSH connection to the R-Pi from any computer on my network. Using PuTTY on two different machines I get an error that says "Unable to open connection to 192.168.0.106. Host does not exist."

I can ping the R-Pi at the address above from other machines.
If I use an IP scanner on another machine I can see the R-Pi and it tells me Port 1024 is open.
I can use Remote Desktop Connection on a Windows PC, log on to the Pi, and operate it successfully.
I can use the keyboard and mouse connected to the Pi and use it just fine as well.
On the R-Pi I can use ps and confirm SSHD is running.

Essentially I have set this up the same as I have several other Debian and Rasbian OS computers. Not sure what to check or where to look next. Wondering if this configuration may be different now in the age of systemd?

Tim
Last edited by tpmcd on Sun Feb 14, 2016 5:20 pm, edited 1 time in total.

jmmec
Posts: 26
Joined: Thu Dec 31, 2015 11:13 pm

Re: SSH Troubleshooting

Sun Feb 14, 2016 2:08 am

Here are two things you can try:

1. You are probably doing this already, but just to be sure, in your case you'll need to explicitly specify port 1024 whenever using ssh, sftp, etc... If you are using Putty to connect, then of course specify 1024 in the "Port" box.

Code: Select all

$ ssh -p 1024 [email protected]
2. When you log into the Pi, run the command below to make sure that 'sshd' is really listening on port 1024. Below is output from my Pi, but of course it is using the standard port 22.

Code: Select all

[email protected]:~ $ sudo netstat -anp | grep sshd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      709/sshd
tcp6       0      0 :::22                   :::*                    LISTEN      709/sshd

tpmcd
Posts: 7
Joined: Mon Jul 30, 2012 4:09 pm

Re: SSH Troubleshooting

Sun Feb 14, 2016 4:24 am

Yes, I forgot to mention that I am able to ssh from the new R-Pi to itself using port 1024. I can also ssh from the R-Pi to another Linux machine on my network without a problem.

When I issue the netstat command I get a similar response to what you show albeit with the expected port 1024 and a different pid number.

When I use PuTTY I have also tried using the name of the R-Pi computer and the specific IP address of the R-Pi. Both fail with the same error described above.

Tim

DirkS
Posts: 9940
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: SSH Troubleshooting

Sun Feb 14, 2016 1:43 pm

I'm a bit puzzled by
2. I edited /etc/ssh/sshd_config and changed the port to 1024 as I already had another machine using Port 22 on the network.
You don't need to use different ports for each SSH server.

jmmec
Posts: 26
Joined: Thu Dec 31, 2015 11:13 pm

Re: SSH Troubleshooting

Sun Feb 14, 2016 3:21 pm

The change you made to move sshd to a different port is fine, and should work since you confirmed that sshd is listening on port 1024, but I too was wondering why you thought it necessary.
tpmcd wrote:Yes, I forgot to mention that I am able to ssh from the new R-Pi to itself using port 1024. I can also ssh from the R-Pi to another Linux machine on my network without a problem.
Leaving Putty / RDP out of the discussion, it is clear that this works: you can ssh from the source 'sshd 1024' machine to a destination Linux machine. But what about the reverse direction? It should work assuming you are doing "ssh -p 1024 ...." from that destination machine to the machine that is running sshd on 1024.

Maybe move the 'sshd 1024' machine back to port 22 unless there are other reasons you need to keep it at 1024.

tpmcd
Posts: 7
Joined: Mon Jul 30, 2012 4:09 pm

Re: SSH Troubleshooting

Sun Feb 14, 2016 4:05 pm

DirkS wrote:I'm a bit puzzled by
2. I edited /etc/ssh/sshd_config and changed the port to 1024 as I already had another machine using Port 22 on the network.
You don't need to use different ports for each SSH server.
If I have multiple machines on my local network that I ultimately want to connect to from the outside world doesn't the different port numbers make it possible to select the particular machine I want? i.e.--mydomain.com, Port 22 is a different machine than mydomain.com, Port 1024?

Tim

tpmcd
Posts: 7
Joined: Mon Jul 30, 2012 4:09 pm

Re: SSH Troubleshooting

Sun Feb 14, 2016 4:12 pm

Leaving Putty / RDP out of the discussion, it is clear that this works: you can ssh from the source 'sshd 1024' machine to a destination Linux machine. But what about the reverse direction? It should work assuming you are doing "ssh -p 1024 ...." from that destination machine to the machine that is running sshd on 1024.
No, regardless of what machine (Linux or Windows) I try to connect with any attempt to use ssh to connect to this R-Pi results in the "Host does not exist" error.

I imagine this will turn out to be something very simple however I've setup simple ssh servers on quite a few Linux machines and a couple of other R-Pi's before and never encountered this.

Tim

User avatar
rpdom
Posts: 15199
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: SSH Troubleshooting

Sun Feb 14, 2016 4:14 pm

tpmcd wrote:If I have multiple machines on my local network that I ultimately want to connect to from the outside world doesn't the different port numbers make it possible to select the particular machine I want? i.e.--mydomain.com, Port 22 is a different machine than mydomain.com, Port 1024?
If connecting from outside, yes.

Some routers let you change the destination port a well as the IP address, so example.com:22 could be mapped to 192.168.1.20:22 and example.com:1024 could be mapped to 192.168.1.30:22. The old router I had could do that. The one I've got now can't.

tpmcd
Posts: 7
Joined: Mon Jul 30, 2012 4:09 pm

Re: SSH Troubleshooting

Sun Feb 14, 2016 4:15 pm

Here is a related question in the interest of troubleshooting.

If I take the R-Pi and load a fresh image with zero changes and enable ssh with the config menu I believe I should be able to ssh to it using Port 22 is that correct? (To test I can shut down everything on the network except the two computers.)

Tim

User avatar
rpdom
Posts: 15199
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: SSH Troubleshooting

Sun Feb 14, 2016 4:24 pm

The standard Raspbian install has ssh enabled by default and you should be able to ssh in on port 22.

tpmcd
Posts: 7
Joined: Mon Jul 30, 2012 4:09 pm

Re: SSH Troubleshooting [SOLVED]

Sun Feb 14, 2016 6:02 pm

I now have SSH access to the R-Pi working. I don't think "solved" is quite correct because I was unable to determine what caused the problem.

A short while ago I downloaded a fresh Raspian image and re-flashed the card. I made no changes to the system and was able to connect via ssh.

Thanks to all who commented.

Tim

Return to “Advanced users”