hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 8:52 am

I have a digitalocean server that i watn to use to orchestrate a couple of RPies with Ansible. I have created the key pair and i'm trying to ssh-copy-id pi@#####... but all i get is this:

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: ERROR: ssh: connect to host ###.###.###.### port 22: Connection timed out

At first I thought it was a firewall issue, but when i connect the Rpies directly with ethernet cables through a switch and try again I still get the same output in the terminal..

It might be an issue with already generated or stored keys on the RPies?

Anybody who know what could be the obstacle?

All help would be much appreciated

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:05 am

if you have created keys like
ssh-keygen -t rsa
then if you can
ssh user@remote.machine
into the remote machine then you should
ssh-copy-id user@remote.machine

as long as it is not user root [unless you have enabled ssh for the root account]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:12 am

The ssh-keys are generated as root. Could that pose a problem?

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:15 am

unless you want the root account to connect just use the users account to generate the keys
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:19 am

yeah thanx:) but i cant copy the id, thats the issue.. doesn't matter if im root or user.

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:28 am

can you ssh in
if not what error
ssh -vv user@remote.machine
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:42 am

ssh: connect to host ###.###.###.### port 22: Connection timed out

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:48 am

And if i run on the remote:
netstat --tcp --listening --programs --numeric

tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 463/sshd
tcp6 0 0 :::22 :::* LISTEN 463/sshd

so the default 22 port is listening on the RPi
Last edited by hyer on Fri Jul 22, 2016 9:49 am, edited 1 time in total.

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:49 am

ssh -vv user@remote.machine

put the -vv in
basically though you have the wrong ip address - you are connecting to a windows box or something that does not have a ssh server running on it
or you have disabled ssh logins
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:51 am

try via IP address
what IP address are you using ?
are they connected via a local router
can you ping the machine ?
and when you get returns , pull the NIC out of the target machine and doers it stop responding
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:52 am

i dont have the wrong IP. i can ssh from one RPi to the other, and i can ping the adresses.. I have done this exercise with a master RPi and a node RPi and that worked.

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:54 am

with debug log, -vv, i get:

root@UbuntuDroplet:/home/kolibri# ssh -vv pi192.168.###.###
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: /etc/ssh/ssh_config line 57: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.###.### [192.168.###.###] port 22.
debug1: connect to address 192.168.###.### port 22: Connection timed out
ssh: connect to host 192.168.###.### port 22: Connection timed out

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 9:58 am

last time...
from the ubuntu server
ping the destination
remove the NIC lead from the destination - does that stop the ping replays ?
if yes then it can reach it
plug it back in
ssh -vv user@destination
what happnes
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:09 am

doesn't work when i ping... Only get:

PING 192.168.###.### (192.168.###.### ) 56(84) bytes of data.

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:14 am

but i can ping the other way, ping the ubuntu server

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:17 am

and i can ping both RPi from each other. But like i said, when i ping one of the RPies from ubuntu it does not seem to recieve any packages.. but i can ping others like google.com etc.

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:20 am

then you don't have a working route from the Ubuntu machine to the RPi you are testing
as you are using 192.168.x.x address you can post them fully as they are none notable across the net

post the results of
ifconfig && route
from all machines
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:27 am

Ubuntu virtual machine:

root@UbuntuDroplet:/home/kolibri# ifconfig && route
eth0 Link encap:Ethernet HWaddr 04:01:2f:16:68:01
inet addr:95.85.x.x Bcast:95.85.20.255 Mask:255.255.255.0
inet6 addr: fe80::601:2fff:fe16:6801/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9859 errors:0 dropped:0 overruns:0 frame:0
TX packets:12915 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6312468 (6.3 MB) TX bytes:1975046 (1.9 MB)

eth1 Link encap:Ethernet HWaddr 04:01:2f:16:68:02
inet6 addr: fe80::601:2fff:fe16:6802/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:743 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:144145 (144.1 KB)

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:134 errors:0 dropped:0 overruns:0 frame:0
TX packets:134 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:9576 (9.5 KB) TX bytes:9576 (9.5 KB)

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 95.85.20.1 0.0.0.0 UG 0 0 0 eth0
10.14.0.0 * 255.255.0.0 U 0 0 0 eth0
95.85.20.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:29 am

pi@raspberrypi:~ $ ifconfig && route
eth0 Link encap:Ethernet HWaddr b8:27:eb:4d:da:b3
inet addr:192.168.x.x Bcast:192.168.x.255 Mask:255.255.255.0
inet6 addr: fe80::46ff:82a6:312f:5275/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:26716 errors:0 dropped:5552 overruns:0 frame:0
TX packets:16576 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1503633 (1.4 MiB) TX bytes:3332413 (3.1 MiB)
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:1906 errors:0 dropped:0 overruns:0 frame:0
TX packets:1906 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:181693 (177.4 KiB) TX bytes:181693 (177.4 KiB)
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default Studie-pc.mshom 0.0.0.0 UG 202 0 0 eth0
192.168.x.x * 255.255.255.0 U 202 0 0 eth0

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:30 am

pi@raspberrypi:~ $ ifconfig && route
eth0 Link encap:Ethernet HWaddr b8:27:eb:c4:15:5c
inet addr:192.168.x.x Bcast:192.168.x.255 Mask:255.255.255.0
inet6 addr: fe80::8645:bb26:f5c8:d099/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82841 errors:0 dropped:4672 overruns:0 frame:0
TX packets:68073 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29580742 (28.2 MiB) TX bytes:13326534 (12.7 MiB)
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:13366 errors:0 dropped:0 overruns:0 frame:0
TX packets:13366 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1210407 (1.1 MiB) TX bytes:1210407 (1.1 MiB)
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default Studie-pc.mshom 0.0.0.0 UG 202 0 0 eth0
192.168.x.0 * 255.255.255.0 U 202 0 0 eth0

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 10:59 am

hyer wrote: eth0 Link encap:Ethernet HWaddr 04:01:2f:16:68:01
inet addr:95.85.x.x Bcast:95.85.20.255 Mask:255.255.255.0

Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 95.85.20.1 0.0.0.0 UG 0 0 0 eth0
10.14.0.0 * 255.255.0.0 U 0 0 0 eth0
95.85.20.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
there we have it ...
your ubuntu cannot reach 192.168.x.x
as it is not on the same network

are they physically in the same place ?
or is it remote...
if remote you need to fix your local network to have a public IP address and route things appropriately ...
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 11:09 am

The ubuntu is not in the same place as the RPies, it is a virtual machine created on digitalocean.com. Is there any guides to how i can fix the adress so i can reach them?
I dont get how the RPies can reach the Ubuntu, but not the other way around..?

User avatar
RaTTuS
Posts: 10563
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 11:21 am

the RPI's can reach there because the internet will route to that server
that server cannot route to 192.168.x.x address as they are a private address
https://en.wikipedia.org/wiki/Private_network
what you need to do is find out what your IP address is
i.e.
https://whatismyipaddress.com/
then [after you have removed the user pi [or at least made it so that it needs only keys to log in , and deffo not have raspberry as the password]]
use the port forwarding options of your router to forward port 22 to the local pi addess [or choose another port and forward that to your pi [or 2 ports to both pi's]]
then you should be able to log in from the remote machine to the local pi's using the public ip address you found earlier
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 11:45 am

Ah.. I get it. Thx alot! But i have tried doing this, connecting the raspies to my router instead of with ethernet cables, and use the service weaved (instead of port forwarding). But it didnt give me any result. I will try a couple of things and then get back to you. Really appreciate your help ^^

hyer
Posts: 22
Joined: Fri Jun 24, 2016 12:33 pm

Re: Can't copy ssh from Ubuntu server to Rpi

Fri Jul 22, 2016 1:59 pm

Finally got a SSH connection. Just needed to use the right host, adress and port. Stupid, i know.
But now my next problem is that i have trouble using ansible with the weaved service, seems like its only possible with one SSH connection at a time on that service. So i might need to handle the forewall issue in another way..

Return to “Troubleshooting”