ssh連不上伺服器問題
git pull時git clone時或putty ssh連不上伺服器時
如果報錯(git 報錯):
ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.
這種情況就需要你去排錯了
首先ssh -v
看看能不能獲得什麼有用的資訊
或者物理登入伺服器,service sshd status
我的伺服器報錯 Could not load host key: /etc/ssh/ssh_ed25519_key
這就是ssh登入不上的原因了。
這種錯誤有兩種情況:
- host key莫名奇妙沒了,或者長度為0(可能是因為病毒)
- (這個就是我為什麼登不上的原因)新版的opensshd 中添加了Ed25519 做簽名驗證,而之前系統裡沒這個演算法的證書(好像是因為重啟伺服器的問題)
- host key不知道為啥沒許可權訪問了,導致ssh失敗(多半是因為777許可權了,SSH 服務會對相關金鑰檔案的許可權進行檢查。比如,私鑰檔案預設許可權是 600,如果配置成 777 等其它許可權,導致其它使用者也有讀取或修改許可權。則 SSH 服務會認為該配置存在安全風險,進而導致客戶端連線失敗。)
最簡單的解決辦法(缺少什麼key就重新生成一遍):
#ed25519_key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key
#rsa_key
ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key
直接重置host key,然後重啟ssh:
service sshd restart
前2個問題都能解決
第三個問題的解決辦法:
cd /etc/ssh/
chmod 600 ssh_host_*
chmod 644 *.pub
操作示意如下:
[[email protected]]# cd /etc/ssh/
[[email protected]]# chmod 600 ssh_host_*
[ [email protected]]# chmod 644 *.pub
[[email protected]]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 668 May 20 23:31 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:31 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:31 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:31 ssh_host_key.pub
-rw------- 1 root root 1675 May 20 23:31 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 May 20 23:31 ssh_host_rsa_key.pub
檢查檔案有效性
如果參閱前述步驟,修改相關檔案許可權後,還是無法正常連線。由於 SSH 服務在啟動時會自動重建丟失的金鑰檔案。所以,也可以直接將相關檔案刪除並重啟 SSH 服務,讓相關檔案自動生成。
相關指令如下:
cd /etc/ssh/
rm -rf ssh_host_*
service sshd restart
操作示意如下:
[[email protected]]# cd /etc/ssh/
[[email protected]]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 672 May 20 23:08 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:08 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:08 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:08 ssh_host_key.pub
-rw------- 1 root root 1675 May 20 23:08 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 May 20 23:08 ssh_host_rsa_key.pub
[[email protected]]# rm -rf ssh_host_*
[[email protected]]# ll
total 132
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
[[email protected]]# service sshd restart
Stopping sshd: [ OK ]
Generating SSH1 RSA host key: [ OK ]
Generating SSH2 RSA host key: [ OK ]
Generating SSH2 DSA host key: [ OK ]
Starting sshd: [ OK ]
[[email protected]]# ll
total 156
-rw-------. 1 root root 125811 Nov 23 2013 moduli
-rw-r--r--. 1 root root 2047 Nov 23 2013 ssh_config
-rw------- 1 root root 3639 May 16 11:43 sshd_config
-rw------- 1 root root 668 May 20 23:16 ssh_host_dsa_key
-rw-r--r-- 1 root root 590 May 20 23:16 ssh_host_dsa_key.pub
-rw------- 1 root root 963 May 20 23:16 ssh_host_key
-rw-r--r-- 1 root root 627 May 20 23:16 ssh_host_key.pub
-rw------- 1 root root 1671 May 20 23:16 ssh_host_rsa_key
-rw-r--r-- 1 root root 382 May 20 23:16 ssh_host_rsa_key.pub
補充說明:對於 Ubuntu 、Debain 類作業系統,修復指令如下:
sudo rm -r /etc/ssh/ssh*key
sudo dpkg-reconfigure openssh-server
還有一種錯誤不是Could not load host key:….的問題
而是錯誤次數太多被列入黑名單了
需要檢查hosts.allow和hosts.deny
這裡兩個檔案在/etc/下。
參考文章:
相關推薦
ssh連不上伺服器問題
git pull時git clone時或putty ssh連不上伺服器時 如果報錯(git 報錯): ssh_exchange_identification: read: Connection reset by peer fatal: Could not
遠端連線連不上伺服器一種解決方法
允許123的使用者使用密碼123來進行遠端登入 GRANT ALL PRIVILEGES ON *.* TO '123'@'%' IDENTIFIED BY '123' WITH GRANT OPTION; 允許123的使用者在ip為192.168.0.1的主機上使用密碼123來
Mac ssh連不上的解決方法
之前在hostus上面申請了一個香港的vps,價效比還蠻高的,蛋疼的是,在公司的網路訪問不了我的vps上面的web伺服器,ssh是可以連上的。於是昨天就想退款,可是收到的回信是說已經過了可以退款的期間,難受香菇。沒轍,今天又只能重新開啟vps,但是當我用ssh連
FileZilla連不上伺服器
剛下載下來的FileZilla連線不上伺服器,百度了一下 說防火牆的事,我就把防火牆關了,果然連上了。。但是第二次再連的時候 ,不知道為什麼,一直連不上,防火牆也關了,最後 連線方式是 sftp 加上埠是 22 就ok 了
能ping通Linux但是ssh連不上,可能的原因
學校的伺服器的ip可以ping通,可以通過網頁訪問伺服器上的openstack,但是ssh無法訪問,所以懷疑是學校把埠禁用了。 解決辦法: 將ssh的埠換為瀏覽器的埠:80 #vi /etc/ssh/sshd_config port=80 儲存後重啟服務: #service
ssh 連不上, 或putty出現 Network error:Software caused connection abort
com ssh auth sshd line cnblogs put soft host https://www.cnblogs.com/netonline/p/7410586.html 89 ls /etc/ssh/ssh_host_rsa_key 90
阿里雲伺服器,客戶端socket連不上的問題
最近弄了個阿里雲的免費試用版,想著把自己的服務丟到阿里雲上去試試。原以為這應該是一件比較順利的事情,卻弄了很久才找到原因。 在阿里雲上安裝完git,將程式碼拉下去編譯完成後,啟動服務一切正常。客戶端我首先ping一下,也沒有問題。注意,這是ping要選用公網地址。但是客戶端程式跑起來時候一直在c
Navicat連不上遠端阿里雲伺服器MySQL資料庫的幾個原因
背景: 今天在阿里雲CentOs裡部署MySQL,用ssh連上可以進入資料庫,但是本地Navicat就是連不上。如圖: 過程:到處看帖子,各種嘗試,過程如下: 1.有的帖子提醒要先開啟mysql服務:systemctl satrt mysqld.service
遠端伺服器系統升級後,使用SSH登陸不上。報錯為Host key verification failed.
主要原因是:系統升級後會重新生成一份主機金鑰,然而自己的機子中儲存的確是之前的金鑰,與遠端主機發送RSA金鑰的指紋不同。所以將自己機子中的金鑰刪除即可。 報錯如下: 1.刪除known_host
雲伺服器重啟後網站打不開及FTP連不上的原因及解決方法
安裝好CENTOS 6.5 後 並安裝了NGINX+MYSQL+PHP後,設定好網站,訪問正常,但重啟後發現網站打不開了,登入伺服器,測試nginx -t 測試正常,說明服務都正常,後來發現是因為防火牆iptables 的關係,因為Linux防火牆(Iptables)重啟系統生效,所以重
騰訊雲伺服器突然遠端連不上
最近弄點東西,突然不能遠端連上騰訊雲的伺服器了,如下 也能ping通伺服器IP,但是就是不能連上,而且也不能正常訪問伺服器之前掛著的網站。 上騰訊雲的官方論壇看別人的相似問題,但還是不能解決
SSH配置出錯導致連線不上伺服器
記錄一下, 由於阿里雲內部更新,導致大部分使用者ssh連線不上伺服器, 並且我最近也有其他的金鑰對操作,所以誤以為是阿里雲ssh金鑰出了問題 修改了配置之後仍沒解決問題, 後來阿里雲更新成功之後,仍然沒有連線上 恢復sshd/config原始配置
ssh只能啟動一個(或者有時候根本連不上)
事情是這樣的,我配置了3臺hadoop,開始的時候是沒有問題的,執行正常,後來放了幾天,然後發現其中一臺機器的ssh連線不上了,但是hadoop的機器之間互相是可以免密登入的,發現用其他的機器進行免密登入這臺機器是可以的。明明之前都是正常的不可能在未動伺服器的情況下sshd自動關閉埠。 ping 此機器IP
eclipse的svn連不上SVN Server伺服器
eclipse安裝的svn外掛連不上windows下裝的svn; 開啟 VisualSVN Server Manager; 1開始列表 2單機 VisualSVN Server
2003伺服器遠端桌面連不上解決辦法
一直都是用XP 連2003伺服器,以前從未出現過問題,早二天突然出現提示:什麼許可還有多少天到期,也沒當回事,想想以前都這樣,也沒出過什麼問題啊,於是就有了今天的一幕,開啟遠端桌面連線,系統提示:終端服務許可證過期,請聯絡管理員。 想想
騰訊雲服務器突然遠程連不上(包含ssh,拒絕訪問)
img bsp 截圖 wid inf alt 雲服務 暫時 info 版權聲明:本文轉載自 https://blog.csdn.net/Alexwu555/article/details/78448113, 暫時這樣 , 以後再來整理。不太習慣不能直接貼截圖啊
伺服器重啟後,MySql連不上?!
今天發現數據庫某表崩潰了(解決方法:https://blog.csdn.net/qq_29729735/article/details/76683433),正想遠端連線一下伺服器,結果發現連線不上:
阿里雲伺服器配置連不上tomcat伺服器
一.先確定在伺服器可否正常開啟 命令列 wget http://localhost:8080檢查 或瀏覽器 http://localhost:8080檢查 二.如果上面沒問題進入阿里雲控制檯: 步
能ping通虛擬機中的Ubuntu,使用XShell連不上
apt telnet open top 說明 使用 bsp shell 安裝 1.在宿主機上telnet 虛擬機ip 22如果顯示端口無法接通,說明你的/etc/init.d/sshd 是stop或者是異常的。 2.如果沒有sshd服務,使用" sudo apt-get
SSH登陸不上
ssh連接不上SSH登陸不上,很多原因。我重啟SSH,登陸不上。報錯:沒有權限,如圖:無論是修改配置文件。還是改配置文件的權限。都不行。最後,QQ群中,網友提醒,SELINUX關了嗎?我一看,沒關!(理所當然,認為關了。)修改,然後就連上了。SSH登陸不上