1

I'm currently having difficulties connecting to an embedded board from my Linux machine through ssh. The embedded board is a FOX G20 V with a Linux OS. I've tried to connect to the board through several ports, I have followed all the solutions online regarding firewall, public/private keys and iptables configuration. Nevertheless, I always get the error message

connect to host port 22: Connection refused

This got me thinking, perhaps I need to check the ssh status on the embedded board and to check what port it's listening on. But since I can't even connect to the board to check this information out, I'm stuck. For what it's worth, I am able to ping to the board.

Does anyone therefore have a solution as to how I can check the ssh status?

0

2 Answers 2

2

Judging from your question, it appears the board is not under your control, otherwise you would know (I presume) which port ssh is listening on, if at all.

If this is indeed the case, then nmap is your only friend (or some other scanner, of course). My suggestion is to do a heavy scan:

  sudo nmap -T5 -A -p1-65535 ip.address.of.board

The flag -T5 reduces the time interval between probes, which should not be a worry for you (you are not trying to go undetected, are you?). The -A flag introduces a number of tests performed through scripts, which may also prove useful. The -p1-65535 makes sure you test all ports, not just the lowest-numbered ones.

This will tell you, except in the presence of elaborate evasive action (port knocking, anyone?), whether an ssh service is listening at all, and on which port.

Of course this implies you are checking on TCP ports, which is the correct choice if you are investigating a possible ssh service. However, most people forget that an nmap scan does not, by default, scan UDP ports; once again, this is irrelevant for ssh, but just for the sake of completeness, if you were trying to do the same for OpenVPN, you would have to issue the command:

 sudo nmap -sU -T5 -A -p1-65535 ip.address.of.board  
6
  • 1
    Thank you for your answer. I'm guessing you meant sudo nmap instead of sudo namp? In any case, I get command not found so I think I have to install it. Knowing that I don't have an internet connection on the machine that I'm working on (this is not it), is there a way I can manually install ùmap? Thank you.
    – Adam
    Apr 24, 2014 at 7:02
  • 1
    @JohnSmith Yes, indeed I meant sudo nmap. You can download the code for nmap here, nmap.org/download.html, load it unto a USB drive, and bring it to the pc without an Internet connection. Apr 24, 2014 at 7:13
  • I notice even with -T1 (1 millisecond rather than 5), it takes over 65sec on my network. it is still going after 3min. any idea why? it sitll seems slow. Anyhow, that aside, a good switch is -v that very quickly displays the open ports as it runs so no need to wait for completion.
    – barlop
    Apr 29, 2014 at 0:06
  • @barlop 1 millisecond per port, 65000-odd ports = 65 sec. Apr 29, 2014 at 5:40
  • @MariusMatutiae yes correct 65 thousand * 65 thousandths is 65. What I am saying is that one might expect that scanning with -T1 would take 65 seconds You seem to think so. But as I said, in my test it does not. It takes over 3min. And -T5 would be longer. Have you timed how long it takes for you to scan 65535 ports with -T1 vs -T5? You may find your assumption of 65sec in your last comment for -T1 doesn't hold up
    – barlop
    Apr 29, 2014 at 11:48
1

nmap of course(i.e. do a port scan). nmap -P0 -p1-65535 5.6.7.8 (where 5.6.7.8 is the ip) maybe somebody has a better idea or better parameters. That -P0 makes it work even if you didn't get a ping response. and scanning all those ports (1-65535) at once may be a bit slow(or perhaps ok on a LAN)

added -v is an excellent switch, it makes nmap show the results as it progresses. that is very fast. nmap -v -P0 -p1-65535 5.6.7.8 (and perhaps you may find -T5 as marius suggests makes it faster)

added as to the other aspect of your question, how to adjust the ssh server port, I haven't checked to see if it's possible to edit sshd_config while logged in but that'd be a path to try. You open sshd_config (it's within /etc e.g. /etc/ssh/sshd_config and it will say e.g. Port 22 so you make a new line and type Port 12345, then restart the system or the sshd server. and (you can use nmap and test your two ports eg 22 and 12345) so see you still have port 22 and that you get the additional port. That(adding an additional port) seems safer than adjusting the one port it is on because if that goes wrong you've locked yourself out. You can always edit again and remove a port. Hopefully sshd_config doesn't lock while logged in, give it a try and report back. Hopefully some know some other ways as it's always good to have multiple methods.

4
  • @JohnSmith you're supposed to click the up/down vote to express that, rather than creating the litter of writing "Thanks" on a website that is for technical content.
    – barlop
    Apr 24, 2014 at 7:56
  • 1
    I'm only at 10 reputation and you need a minimum of 15 reputation :) If you upvote my question I'd be able to upvote the answer!
    – Adam
    Apr 24, 2014 at 7:57
  • 1
    @JohnSmith I did already but I just upvoted your other questions so that should do it
    – barlop
    Apr 24, 2014 at 7:58
  • Thanks just upvoted your's too. Thanks for your added answer. I'll take a look at that as well!
    – Adam
    Apr 24, 2014 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .