こういうエラーをどう対応するか?
Windowsではchown,chmodとかできない。でもcygwinは嫌いな人向け。
CurrentDir> ssh hoge
The authenticity of host 'hoge' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (C:\\Users\\sugimura/.ssh/known_hosts).
sugimura@hoge: Permission denied (publickey).
Windowsはuser直下フォルダはadminもアクセス可能になっていて、user onlyのpermissionとしてDocumentsを使うみたい。
したがって下記のようにconfigとkeyの格納フォルダを分けておくとうまくいく。
すごく残念
- sshのconfigファイルは %homepath%.ssh フォルダに置いておく
- sshのkeyファイルは %homepath%\Documents.ssh フォルダに置いておく
- configファイルでのIdentityFileの指定は ~/Documents/.ssh/ とする
なお、configファイル内はpath separatorが\でも/でもいいみたい。
mac, linuxとの互換性(Documents/を消すだけなので修正が容易)を考えて"/"を使ってる。
過去情報
コマンドで頑張ってWindows内部のPermissionを制御する方法
こんな感じのコマンドで行けます。****は自分のファイル名に置き換えてください。
- コマンドプロンプトを管理者モードで起動
- コマンドプロンプト起動時に,右クリックで管理者で実行すればよい。
anyDir> cd %USERPROFILE%
CurrentDir> takeown /F .ssh /A
CurrentDir> takeown /F .ssh
CurrentDir> icacls .ssh /grant Administrators:F
anyDir> cd ~/.ssh
CurrentDir> takeown /F <publickey> /A
CurrentDir> takeown /F <publickey>
CurrentDir> icacls <publickey> /grant Administrators:F