【发布时间】:2015-07-23 05:05:20
【问题描述】:
所以我想通过我的 macbook pro 使用 SSH 来控制我的香蕉派。这是我第一次使用 ssh。所以我遵循了很多不同的教程,但它仍然不起作用。 如果我跑:
pi@172.25.54.12
或
bananapi@172.25.54.12
或者我尝试的任何名称都会回答我的问题
ssh: 连接到主机 172.25.*.*2 端口 22: 操作超时
当我尝试时
bananapi@localhost
或
pi@localhost
它回答我:
ssh:连接到主机 localhost 端口 22:连接被拒绝
我发现我的 IP 地址在我的香蕉皮上执行 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
有什么想法吗?
编辑: 所以按照 cmets 的建议,我做了一个:
$ 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 文件中有一个密钥。
我必须将它(公钥)发送到我的香蕉派吗?
编辑#2: 这是我的隐藏地址 172.25.54.12 我现在想要的只是将我的 mac 连接到我的香蕉 pi 并将其作为服务器进行控制。所以我的 Mac 是客户端,我的香蕉派是我的“主机”。 当我跑步时
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的SSH密钥在
authorizedkeysfile .ssh/authorized_keys .ssh/authorized_keys2 -
nop 我的本地地址 ip 就像 172.25.x.x
-
我怎么能验证这个?
-
使用this 并检查密钥是否在
.ssh/authorized_keys中。顺便说一句,172.25 也是本地 IP 地址 :) -
你的问题不是很清楚。您能否阐明您正在运行的确切 ssh 命令,以及您在哪个主机(mac 或 pi)上运行它们?另外,在 pi 上,您可以运行
netstat -an | grep 22并将输出包含在您的问题中吗?如果您没有隐藏太多您正在使用的地址,这也会很有帮助。