使用 mac ssh Banana pi

ssh Banana pi with mac

所以我想用我的 macbook pro 使用 SSH 控制我的香蕉派。这是我第一次使用 ssh。所以我遵循了很多不同的教程,但它仍然不起作用。 如果我 运行 :

pi@172.25.54.12

bananapi@172.25.54.12

或者我尝试的任何名称都会回答我

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

当我尝试

bananapi@localhost

pi@localhost

它回答了我:

ssh: connect to host localhost port 22: Connection refused

我发现我的 IP 地址在我的 bananapi 上执行 ifconfig。 我的 bananapi 使用的是 bananian(香蕉派的 debian),我的 mac 是 10.10.3.

当我 运行 sshd -T 时,我有:

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

有什么想法吗?

编辑: 所以按照评论中的建议,我做了一个:

$ 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 –

这就是我得到的答案。所以我在 authorized_keys 文件中有一个密钥。 我必须将它(public 键)发送到我的香蕉派吗?

编辑#2: 这是我不太隐藏的地址 172.25.54.12 我现在只想将我的 mac 连接到我的 banana pi 并将其作为服务器进行控制。所以我的 Mac 是客户端,我的香蕉 pi 我的 "host"。 当我运行

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

基本上我所做的是,我按照互联网上的一些教程(比如这个https://www.youtube.com/watch?v=0wn44MbxtZw)但是它不起作用。

编辑#3: 我尝试使用 PC 和 PuTTY,但出现错误: 网络错误:网络无法访问。

也许能帮上忙。

编辑#4

好的,我理解了部分问题:我认为可以在不使用本地网络的情况下直接连接我的两个设备。我的意思是直接用一根以太网电缆将我的香蕉派连接到我的 mac。但我的目标是即使没有连接到任何网络也能连接到我的香蕉派(这可能吗?),所以我想使用静态 IP 地址,这是个好主意吗?

好的,所以我找到了一种方法来做我想做的事。这意味着只需使用以太网电缆(交叉以太网电缆)直接连接我的 mac 和我的香蕉派。 我编辑了网络接口:

gedit /etc/network/interfaces

然后我这样修改了文件

#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.*

所以对于地址,我输入了一个与我的 Mac IP 地址非常相似的 IP(以获取 mac IP 地址 运行 ipconfig getifaddr en0) 对于网关,我输入了 mac IP 地址。

然后我用交叉以太网电缆连接了我的两个设备。在我的 mac 终端中,我 运行:

bananapi@169.x.y.*

成功了!

谢谢