[問題] 無法連 SSH 到 Scientific linux
大家好,小弟一直無法用 ssh 連到 Scientific linux ..
我的 linux 版本如下:
NAME="Scientific Linux"
VERSION="7.5 (Nitrogen)"
ID="rhel"
ID_LIKE="scientific centos fedora"
我參考了這篇文章:
How to open SSH port 22 on Rehdat 7 Linux server
https://linuxconfig.org/how-to-open-ssh-port-22-on-rehdat-7-linux-server
我發現到 Sci-linux 並非使用 iptables 作為防火牆,而是 firewalld。
於是我按照那篇文章的指示,輸入了以下指令:
firewall-cmd --zone=public --add-port=22/tcp --permanent
出現底下訊息:
Warning: ALREADY_ENABLED: 22:tcp
success
我想這應該是開成功了,此外我也輸入了 iptables-save | grep 22 以進一步確認。
出現的訊息如下,符合該網頁的說明,我想應該也是OK
-A IN_public_allow -p tcp -m tcp --dport 22 -m conntrack --ctstate NEW
-j ACCEPT
然而,當我試著連線到學校實驗室主機時:
我在自己 Macbook pro 終端機輸入 ssh 140.xxx.xxx.xxx
結果沒反應,後來出現
ssh: connect to host 140.xxx.xxx.xxx port 22: Operation timed out
我接著使用 ping 指令,輸入 ping 140.xxx.xxx.xxx,得到看似很正常的反應
64 bytes from 140.xxx.xxx.xxx: icmp_seq=15 ttl=52 time=18.593 ms
64 bytes from 140.xxx.xxx.xxx: icmp_seq=30 ttl=52 time=12.203 ms
64 bytes from 140.xxx.xxx.xxx: icmp_seq=31 ttl=52 time=26.094 ms
64 bytes from 140.xxx.xxx.xxx: icmp_seq=32 ttl=52 time=214.384 ms
64 bytes from 140.xxx.xxx.xxx: icmp_seq=33 ttl=52 time=14.329 ms
就這樣無止盡下去。而當我接著使用 traceroute 140.xxx.xxx.xxx 之後,
好像就出現了問題?我不是很確定...大致來說,前面 12 行的指令,看起來像是
有成功通過每個網路節點(不知道是這個意思嗎?),但在那之後,就出現了很多
似乎保密的米字符號:
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *
就一直持續下去...我現在已經不知問題出在哪了 QQQQ
ps.
其實這問題持續半年多了,過去半年我偶爾都會上網查詢嘗試不同的方法。
包括停用 firewalld ,改用 iptables 防火牆,然後開啟 port 22,但是
都沒有用,而 ping & traceout 的反應「好像」都一樣(不確定)。
我也得很抱歉地說,我不確定是不是有改到不應該改的東西。
因為過去半年實在嘗試太多方法了,但我想目前應該還OK?
可以正常上網,下載東西等。
還請各位大大協助 真的千拜託萬拜託了 QQQQQQ
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.192.0.245
※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1550678722.A.B69.html
→
02/21 00:10,
5年前
, 1F
02/21 00:10, 1F
謝謝大大 我沒執行哈哈 我想說他都警告我已經開啟 port 22 了,我現在就來試試看
更新:剛執行了大大的 reload 指令,有 success,但是 ssh, ping and traceout
的結果都相同。SSH 仍然 Operation timed out... ><
→
02/21 00:17,
5年前
, 2F
02/21 00:17, 2F
是哦!我並不清楚,我將 traceout 的結果貼上來給大大看一下...我不知道連到哪了QQ
還請大大幫忙我 QQQQ 真的十分感謝您 <(__)>
traceroute to 140.112.33.143 (140.112.33.143), 64 hops max, 52 byte packets
1 hitronhub.home (192.168.0.1) 132.138 ms 5.769 ms 7.013 ms
2 10.37.128.1 (10.37.128.1) 35.093 ms 216.563 ms 26.936 ms
3 10.4.18.105 (10.4.18.105) 25.157 ms 17.922 ms 44.336 ms
4 211-76-114-254.static.kbronet.com.tw (211.76.114.254) 19.822 ms 19.032 ms 26.316 ms
5 219-80-241-237.static.tfn.net.tw (219.80.241.237) 32.811 ms
219-80-240-185.static.tfn.net.tw (219.80.240.185) 135.448 ms 23.184 ms
6 60-199-4-225.static.tfn.net.tw (60.199.4.225) 16.689 ms 21.537 ms 10.238 ms
7 60-199-3-126.static.tfn.net.tw (60.199.3.126) 28.548 ms 14.668 ms
60-199-3-134.static.tfn.net.tw (60.199.3.134) 25.886 ms
8 60-199-16-229.static.tfn.net.tw (60.199.16.229) 29.376 ms
60-199-16-237.static.tfn.net.tw (60.199.16.237) 16.694 ms
60-199-16-229.static.tfn.net.tw (60.199.16.229) 23.473 ms
9 211-78-221-26.static.tfn.net.tw (211.78.221.26) 20.222 ms 14.921 ms 25.351 ms
10 140.112.0.69 (140.112.0.69) 44.549 ms 111.440 ms 21.449 ms
11 140.112.0.201 (140.112.0.201) 14.756 ms 55.342 ms 16.401 ms
12 140.112.0.173 (140.112.0.173) 28.247 ms
140.112.0.213 (140.112.0.213) 18.870 ms 25.315 ms
→
02/21 00:20,
5年前
, 3F
02/21 00:20, 3F
我在家裡的 macbook air 上輸入 ssh -vvv ip 得到的結果是
Ethan-de-MacBook-Air:~ Ethan$ ssh -vvv 140.112.33.143
OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: resolve_canonicalize: hostname 140.112.33.143 is address
debug2: ssh_connect_direct
debug1: Connecting to 140.112.33.143 [140.112.33.143] port 22.
而在實驗室的電腦則是(目前用Chrome remote)
ssh: Could not resolve hostname auth: Name or service not known
這是怎麼回事QQQQ
→
02/21 00:24,
5年前
, 4F
02/21 00:24, 4F
→
02/21 00:25,
5年前
, 5F
02/21 00:25, 5F
我不確定...但我以前好像也碰過「開啟sshd」這種議題,只是後續如何我忘記了Orz
指定登入用的使用者名稱?我想說直接連 ip 即可?但 linux 確實有個別於 root
的 user 帳號,我來試試看在 mac 上用 ssh 連 帳號@ip 看看...至於 sshd,待會
上網查查怎麼開 ><
更新:在 mac 終端機連 ssh 帳號@ip 之後,還是 Operation timed out ...
我上網找找看什麼是 sshd & 怎麼開啟 QQ
※ 編輯: Philethan (123.192.0.245), 02/21/2019 00:30:47
→
02/21 00:37,
5年前
, 6F
02/21 00:37, 6F
→
02/21 00:38,
5年前
, 7F
02/21 00:38, 7F
感謝大大 剛還在看底下這篇
Can not connect via sshd on scientific linux 6
https://reurl.cc/Ye7kx
看了 /var/log/secure,感覺沒什麼異狀 QQQ
剛執行大大的程式碼後,得出:
root 1075 0.0 0.0 112808 4288 ? Ss 2月18 0:00 /usr/sbin/sshd -D
root 10771 0.0 0.0 112728 972 pts/4 S+ 00:40 0:00 grep --color=auto sshd
QQ
→
02/21 00:55,
5年前
, 8F
02/21 00:55, 8F
剛剛小弟查了些資料,輸入了 netstat -a | more,得到
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
此外, 輸入大大的指令後,得到
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
這...QQ
真是麻煩大大了 ><
→
02/21 01:04,
5年前
, 9F
02/21 01:04, 9F
執行 ssh 是什麼意思QQ 是指我在實驗室 linux 主機上,使用 ssh 連線到
我自家的電腦看看嗎?如果是這樣,那也是 operation timed out...
ssh 123.192.0.245
ssh: connect to host 123.192.0.245 port 22: Connection timed out
※ 編輯: Philethan (123.192.0.245), 02/21/2019 01:10:31
→
02/21 01:11,
5年前
, 10F
02/21 01:11, 10F
→
02/21 01:12,
5年前
, 11F
02/21 01:12, 11F
謝謝大大:)
目前嘗試第一個 ip 應該可以,第二個不行 ..
ssh 127.0.0.1
root@127.0.0.1's password:
Last login: Thu Feb 21 00:28:50 2019
ssh 140.112.33.143
ssh: connect to host 140.112.33.143 port 22: Connection timed out
※ 編輯: Philethan (123.192.0.245), 02/21/2019 01:19:17
推
02/21 01:31,
5年前
, 12F
02/21 01:31, 12F
推
02/21 02:39,
5年前
, 13F
02/21 02:39, 13F
→
02/21 02:40,
5年前
, 14F
02/21 02:40, 14F
推
02/21 02:46,
5年前
, 15F
02/21 02:46, 15F
→
02/21 02:46,
5年前
, 16F
02/21 02:46, 16F
→
02/21 02:47,
5年前
, 17F
02/21 02:47, 17F
→
02/21 02:47,
5年前
, 18F
02/21 02:47, 18F
推
02/21 09:03,
5年前
, 19F
02/21 09:03, 19F
推
02/21 11:42,
5年前
, 20F
02/21 11:42, 20F
→
02/21 21:51,
5年前
, 21F
02/21 21:51, 21F
謝謝大家回覆,經由 bamchisu 大大的協助,發現是路由器沒設定好 port forwarding
導致的,現在已經搞定囉,非常感謝大家!
※ 編輯: Philethan (123.192.0.245), 02/22/2019 01:37:39