2017
Sep
16

我很常使用 .ssh/config 建立 tunnel 連線,有一天突然 ssh 連線一直出現 "bash: No such file or directory" 這個錯誤,上網查了很久,有人說是 chroot 後,預設 bash 的目錄失效,也有人說 user 沒有加到 /etc/group,但這些都不是我遇到的情況,自已找了很久之後,終於發現是環境變數 SHELL 造成的影響。

錯誤訊息
  1. $ ssh xxxx.com.tw
  2. bash: No such file or directory
  3. ssh_exchange_identification: Connection closed by remote host
問題原因
  1. $ env |grep SHEL
  2. SHELL=bash

解決方式將 SHELL 改成絕對路徑 export SHELL=/bin/bash

如果想要每次開機就有正確的設定,可以在 ~/.bash_profile 中加入 "export SHELL=/bin/bash"


回應 (Leave a comment)