Search code examples
linuxmacossshbanana-pi

ssh Banana pi with mac


So I want to control my banana pi with my macbook pro using SSH. It is the first I am using ssh. So I followed a lot of different tutorials and it still does not work. If I run :

pi@172.25.54.12

or

bananapi@172.25.54.12

or whatever name I try it answers me that

ssh: connect to host 172.25.*.*2 port 22: Operation timed out

and when I try

bananapi@localhost

or

pi@localhost

it answers me:

ssh: connect to host localhost port 22: Connection refused

I found my IP address doing ifconfig on my bananapi. My bananapi is using bananian (debian for banana pi), and my mac is 10.10.3.

When I run sshd -T, I have:

port 22
protocol 2
addressfamily any
listenaddress 0.0.0.0:22
listenaddress [::]:22
usepam 1
serverkeybits 768
logingracetime 120
keyregenerationinterval 3600
x11displayoffset 10
maxauthtries 6
maxsessions 10
clientaliveinterval 0
clientalivecountmax 3
permitrootlogin yes
ignorerhosts yes
ignoreuserknownhosts no
rhostsrsaauthentication no
hostbasedauthentication no
hostbasedusesnamefrompacketonly no
rsaauthentication yes
pubkeyauthentication yes
kerberosauthentication no
kerberosorlocalpasswd yes
kerberosticketcleanup yes
gssapiauthentication no
gssapikeyexchange no
gssapicleanupcredentials yes
gssapistrictacceptorcheck yes
gssapistorecredentialsonrekey no
passwordauthentication yes
kbdinteractiveauthentication no
challengeresponseauthentication no
printmotd no
printlastlog yes
x11forwarding yes
x11uselocalhost yes
strictmodes yes
tcpkeepalive yes
permitblacklistedkeys no
permitemptypasswords no
permituserenvironment no
uselogin no
compression delayed
gatewayports no
usedns no
allowtcpforwarding yes
useprivilegeseparation yes
pidfile /var/run/sshd.pid
xauthlocation /usr/bin/xauth
ciphers aes256-ctr,aes128-ctr
macs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
loglevel INFO
syslogfacility AUTH
authorizedkeysfile .ssh/authorized_keys .ssh/authorized_keys2
hostkey /etc/ssh/ssh_host_rsa_key
acceptenv LANG
acceptenv LC_*
subsystem sftp /usr/lib/openssh/sftp-server
maxstartups 10:30:100
permittunnel no
ipqos lowdelay throughput
permitopen any

Any idea?

edit: so as suggested in the comments, I did a :

$ ls -al ~/.ssh
total 24  drwx------ 5 ***************** staff 170 12 mai 13:27 . 
drwxr-xr-x 53 **************** staff 1802 12 mai 11:16 .. 
-rw------- 1 ***************** staff 1766 12 mai 11:16 authorized_keys 
-rw------- 1 ***************** staff 1679 12 mai 13:27 id_rsa 
-rw-r--r-- 1 ***************** staff 429 12 mai 13:27 id_rsa.pub –

This is what I get as an answer. So I have a key in the authorized_keys file. Do I have to send it (the public key) to my banana pi?

edit#2: here is my adress less hidden 172.25.54.12 All I want for now is just connect my mac to my banana pi and control it as a server. So my Mac would be the client, and my banana pi my "host". When I run

netstat -an | grep 22

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      
tcp6       0      0 :::22                   :::*           LISTEN      
udp        0      0 0.0.0.0:32622           0.0.0.0:*      
unix  3      [ ]         STREAM     CONNECTED     4122      
unix  3    [ ]         STREAM     CONNECTED     2922     @/tmp/.X11-unix/X0

Basically what I did is, I followed some tutorial on the internet (like this one https://www.youtube.com/watch?v=0wn44MbxtZw) but it does not work.

edit#3: I tried with a PC and puTTY, and I have got an error: Network error: Network is unreachable.

Maybe it can help.

Edit#4

Ok I understood a part of my problem: I thought it was possible to connect directly my two devices without using the local network. I mean directly connect my banana pi to my mac just with one ethernet cable. But my goal is to be able to connect to my banana pi even when it is not connected to any network (is thath possible?), so I want to use an static IP address, is that a good idea?


Solution

  • Ok, so I found a way to do what I wanted to do. That means to connect directly my mac with my banana pi just with an ethernet cable (cross over ethernet cable). I edited the network interface doing:

    gedit /etc/network/interfaces
    

    and then I modified the file this way

    #interfaces (5) file used by ifup(8° and ifdown(8)
    auto lo
    iface lo inet loopback
    
    #dhcp configuration
    allow-hotplug eth0
    #iface eth0 inet dhcp
    #static ip configuration
    auto eth0
    iface eth0 inet static
    adress 169.x.y.z
    netmask 255.255.255.0
    gateway 169.X.Y.*
    

    So for address I put an IP really similar to my Mac IP adress (to get the mac IP address run ipconfig getifaddr en0) And for gateway I put my mac IP address.

    Then I connected my two devices with a cross over ethernet cable. And in my mac terminal I ran:

    bananapi@169.x.y.*

    and it worked!

    Thank you