Skip to main content
Visitor II
May 11, 2022
Question

ssh: connect to host xx.xx.xx.xx port 22: Connection timed out error on Ubuntu Terminal

  • May 11, 2022
  • 3 replies
  • 3360 views

On the host computer, i try to connect the terminal to the STM32MP157F-EV1 board using ssh with Ethernet cable but I can't access 

I use STM32MP157F-EV1 board. I set manually the IP adress of board with

Board $> ifconfig eth0 uuu.***.yyy.zzz

then I try connect ssh root of board with this command on my Terminal:

ssh root@xx.xx.xx.xx

and then I get

ssh: connect to host xx.xx.xx.xx port 22: Connection timed out error.

 How i can fix this issue. Can anyone help me?

Kind regards

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    May 11, 2022

    Hello @Emre Avcı​ ,

    You have this two pages on the wiki:

    But I think that you already seen them.

    Normally you have this kind of error:

    $ ssh root@192.168.7.1

    ssh: connect to host 192.168.7.1 port 22: Connection refused

    If you are trying to connect to an non existing ip.

    To help you, please can I have the complete traces of the command "ifconfig" on your board

    and the command "ifconfig" or "ip address" of your Ubuntu PC.

    Regards,

    Kevin

    EavciAuthor
    Visitor II
    May 11, 2022

    Hello

    I have already reviewed two pages the two pages you have sent.

    If I explain step by step what I did:

    Firstly command "ifconfig" on my board:

    0693W00000NpnPJQAZ.png 

    Ifconfig responds eth0 that has not IP adress. Therefore I set manually IP adress this command and type ifconfig again:

    0693W00000NpnPsQAJ.png 

    Finally on my host computer, I want to connect the terminal to the board using ssh:

    0693W00000NpnQHQAZ.png 

    I take ssh: connect to host 192.168.72.1 port 22: Connection timed out error

    The command ifconfig on my Ubuntu PC

    0693W00000NpnQrQAJ.png 

    Thanks

    Regards

    ST Employee
    May 12, 2022

    Hi @Emre Avcı​ 

    do you have an IP route between your Ubuntu station and your STM32MP board?

    Run the command from your Ubuntu station:

    ping 192.168.172.1

    or to get defined IP routes

    ip route

    If you can't reach your STM32MP board, that means you have no defined IP route and you need to create one with the command

    ip route add

    Best regards,

    --JM

    Technical Moderator
    May 12, 2022

    Hello @Emre Avcı​ ,

    From what I see with your screenshot, you don't have a subnet shared between your board and your PC so you can't communicate between them.

    For example, on my PC with my DK2 plugged via usb0 (ethernet):

    0693W00000NppfYQAR.pngThe IP of the board is 192.168.7.1

    and on my PC Ubuntu:

    0693W00000NppfnQAB.pngMy IP is 192.168.7.162

    The subnet of my PC and my board is : 192.168.7

    So they are able to communicate together:

    $ ping 192.168.7.1
    PING 192.168.7.1 (192.168.7.1) 56(84) bytes of data.
    64 bytes from 192.168.7.1: icmp_seq=1 ttl=64 time=977 ms
    64 bytes from 192.168.7.1: icmp_seq=2 ttl=64 time=0.888 ms
    64 bytes from 192.168.7.1: icmp_seq=3 ttl=64 time=2.07 ms
    ^C
    --- 192.168.7.1 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2003ms
    rtt min/avg/max/mdev = 0.888/326.706/977.157/459.938 ms

    Please read some pages on internet about how the subnet works, it will help you to understand this behavior.

    -----------

    On your first screenshot, you have an interface usb0 with an ip 192.168.7.1, but on the PC, you do not have this new interface. Is it normal?

    And do you really need to access by SSH with the port ethernet? Or can you use the usb0 interface?

    Regards,

    Kevin

    EavciAuthor
    Visitor II
    May 12, 2022

    Hi,

    I don't understand what do you mean " but on the PC, you do not have this new interface. 

    Is it normal?"

    With usb0, PC and board communicate each other. When I do ping test:

    $ ping 192.168.7.1
    PING 192.168.7.1 (192.168.7.1) 56(84) bytes of data.
    64 bytes from 192.168.7.1: icmp_seq=1 ttl=63 time=1.09 ms
    64 bytes from 192.168.7.1: icmp_seq=2 ttl=63 time=1.42 ms
    64 bytes from 192.168.7.1: icmp_seq=3 ttl=63 time=1.82 ms
    64 bytes from 192.168.7.1: icmp_seq=4 ttl=63 time=1.56 ms
    ^C
    --- 192.168.7.1 ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3068ms
    rtt min/avg/max/mdev = 1.089/1.471/1.819/0.263 ms

    But I want to that board and PC communicate each other by SSH with ethernet cable.

    And what is usb0? Which interface does usb0 use such as ST-Link or UART? There are two connections between my baord and PC: ST-Link and USB-OTG as USB and Etheret cable.

    Regards

    EavciAuthor
    Visitor II
    May 13, 2022

    Hi

    I solved this problem.

    First I set Board IP as statice ip:

    root@stm32mp1:~# ifconfig
    eth0 Link encap:Ethernet HWaddr 00:80:E1:01:67:2D 
     inet addr:192.168.72.2 Bcast:192.168.72.255 Mask:255.255.255.0
     inet6 addr: fe80::280:e1ff:fe01:672d/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
     RX packets:3954 errors:0 dropped:0 overruns:0 frame:0
     TX packets:1479 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000 
     RX bytes:389397 (380.2 KiB) TX bytes:110373 (107.7 KiB)
     Interrupt:60 
     
    lo Link encap:Local Loopback 
     inet addr:127.0.0.1 Mask:255.0.0.0
     inet6 addr: ::1/128 Scope:Host
     UP LOOPBACK RUNNING MTU:65536 Metric:1
     RX packets:970 errors:0 dropped:0 overruns:0 frame:0
     TX packets:970 errors:0 dropped:0 overruns:0 carrier:0
     collisions:0 txqueuelen:1000 
     RX bytes:81460 (79.5 KiB) TX bytes:81460 (79.5 KiB)
     
    usb0 Link encap:Ethernet HWaddr B2:7C:6A:40:F8:35 
     inet addr:192.168.7.1 Bcast:192.168.7.255 Mask:255.255.255.0
     inet6 addr: fe80::b07c:6aff:fe40:f835/64 Scope:Link
     UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
     RX packets:2927 errors:0 dropped:0 overruns:0 frame:0
     TX packets:356 errors:0 dropped:1 overruns:0 carrier:0
     collisions:0 txqueuelen:1000 
     RX bytes:319747 (312.2 KiB) TX bytes:77331 (75.5 KiB)
     

    And second plug USB-OTG cable to my computer and board and I enabled it in the devices tab in VirtualBox and disable and enable the connect network adapter tab in VirtualBox.

    But I don't understand this issue:

    First I give power my STM32MP157F-EV1 Board and ping test with ethernet cable:

    ping 192.168.72.2
    PING 192.168.72.2 (192.168.72.2) 56(84) bytes of data.
    ^C
    --- 192.168.72.2 ping statistics ---
    42 packets transmitted, 0 received, 100% packet loss, time 42019ms

    I don't receive any package in ping test. In this situation, when I connect USB-OTG cable and ping test again while ethernet cable is connected:

    ~$ ping 192.168.72.2
    PING 192.168.72.2 (192.168.72.2) 56(84) bytes of data.
    64 bytes from 192.168.72.2: icmp_seq=1 ttl=64 time=3.33 ms
    64 bytes from 192.168.72.2: icmp_seq=2 ttl=64 time=10.4 ms
    64 bytes from 192.168.72.2: icmp_seq=3 ttl=64 time=18.1 ms
    64 bytes from 192.168.72.2: icmp_seq=4 ttl=64 time=21.8 ms
    64 bytes from 192.168.72.2: icmp_seq=5 ttl=64 time=16.5 ms
    ^C
    --- 192.168.72.2 ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 4039ms
    rtt min/avg/max/mdev = 3.327/14.015/21.812/6.487 ms

    Ping test is doing successfully. And take out ethernet cable and ping test again while USB-OTG cable is connected:

    ~$ ping 192.168.72.2
    PING 192.168.72.2 (192.168.72.2) 56(84) bytes of data.
    ^C
    --- 192.168.72.2 ping statistics ---
    33 packets transmitted, 0 received, 100% packet loss, time 32789ms

    The ping test is not performing successfully. Plug ethernet cable again and ping test:

    $ ping 192.168.72.2
    PING 192.168.72.2 (192.168.72.2) 56(84) bytes of data.
    64 bytes from 192.168.72.2: icmp_seq=1 ttl=64 time=12.1 ms
    64 bytes from 192.168.72.2: icmp_seq=2 ttl=64 time=20.6 ms
    64 bytes from 192.168.72.2: icmp_seq=3 ttl=64 time=10.8 ms
    64 bytes from 192.168.72.2: icmp_seq=4 ttl=64 time=3.94 ms
    64 bytes from 192.168.72.2: icmp_seq=5 ttl=64 time=6.42 ms
    64 bytes from 192.168.72.2: icmp_seq=6 ttl=64 time=7.98 ms
    ^C
    --- 192.168.72.2 ping statistics ---
    6 packets transmitted, 6 received, 0% packet loss, time 5017ms
    rtt min/avg/max/mdev = 3.936/10.294/20.600/5.328 ms

    Take out USB-OTG and ping test with ethernet cable:

    ~$ ping 192.168.72.2
    PING 192.168.72.2 (192.168.72.2) 56(84) bytes of data.
    ^C
    --- 192.168.72.2 ping statistics ---
    58 packets transmitted, 0 received, 100% packet loss, time 58660ms

    The ping test is not performing successfully. I take out ethernet cable and plug again

    when USB-OTG cable disconnect:

    ~$ ping 192.168.72.2
    PING 192.168.72.2 (192.168.72.2) 56(84) bytes of data.
    ^C
    --- 192.168.72.2 ping statistics ---
    22 packets transmitted, 0 received, 100% packet loss, time 21621ms

    The ping test is not performing successfully.

    The thing I'm wondering about is:

    Is necessary USB-OTG connection to between Board and PC for ethernet connection with ethernet cable (eth0) and why it is necessary?

    Regards