
我透過 ssh 連接到遠端伺服器,如下所示:
ssh [email protected]
這個過程工作正常,因為我有密碼可以進入我需要使用的伺服器。
我想為 IP 位址設定名稱,因為我想讓過程更順利,並避免每次都鍵入和記住伺服器 IP。
我已經編輯了/etc/hosts
添加 IP 並連結到新名稱的文件,如下(第二行):
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
::1 localhost
128.x.x.x newname
我已經用以下命令刷新了 DNS 快取:
sudo killall -HUP mDNSResponder; sleep 2; echo macOS DNS Cache Reset | say
然而,當透過以下命令從終端呼叫 ssh 伺服器時:
ssh user@newname
該命令不起作用並顯示以下錯誤訊息:
ssh: connect to host newname port 22: Operation timed out
歡迎任何建議謝謝!