Mac で SSH ログインするときに ssh: Could not resolve hostname xxx : nodename nor servname provided, or not known が出た場合の対応

.ssh/config に色々書いて ssh する時に下記エラーが出た。

$ ssh xxx
ssh: Could not resolve hostname xxx : nodename nor servname provided, or not known

所有者確認

今回ファイルが存在するのに何故かエラーが出ていたのは所有権の問題だった。
config ファイルの所有権が root になっていたので変更する。

$ ls -la .ssh
drwx------   8 macuser   staff   256  6  9 16:45 .
drwxr-xr-x+ 68 macuser   staff  2176  6  9 16:45 ..
-rw-------   1 root  staff   362  6  9 16:39 config
-rw-------   1 macuser   staff  1679  5 31  2015 id_rsa


$ sudo chown -R macuser:staff .ssh

$ ls -la .ssh
drwx------   8 macuser   staff   256  6  9 16:45 .
drwxr-xr-x+ 68 macuser   staff  2176  6  9 16:45 ..
-rw-------   1 macuser   staff   362  6  9 16:39 config
-rw-------   1 macuser   staff  1679  5 31  2015 id_rsa

確認

$ ssh xxx

# yes を入力してエンター
The authenticity of host '123.456.78.9 (123.456.78.9)' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxx.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?

関連記事