LoginSignup
3
1

More than 3 years have passed since last update.

Windows 10 でssh接続を改善する

Last updated at Posted at 2020-10-05

Windows 10 20.04 (20H1)標準のOpenSSHは以下エラーが出て接続ができないことがある。

warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)

解決策は、最新の OpenSSH をインストールし利用する。

Win32-OpenSSH

Download

インストール

  • 実行ファイル
    • C:\a\OpenSSH-Win64\ に展開
  • .ssh/config
    • $HOME/.ssh/config に保管する。

PowerShell からの利用

管理者権限で実行
Set-ExecutionPolicy Unrestricted
編集
New-item –type file –force $profile
notepad $Profile
$profile
function ssh() {
    c:\a\OpenSSH-Win64\ssh.exe $args
}
function scp() {
    c:\a\OpenSSH-Win64\scp.exe $args
}

動作確認

# バージョンが8.1であることを確認。
ssh -V

Git for Windows 付属の OpenSSHを使う場合

$profile
function ssh() {
    c:\PROGRA~1\Git\usr\bin\ssh.exe $args
}
function scp() {
    c:\PROGRA~1\Git\usr\bin\scp.exe $args
}

Program Filesが空白が混ざっているため、PROGRA~1に書き換えた。
短縮名の確認はdir c:\ /xでわかる。


ssh-agent

  • ssh鍵のパスワードを記憶してもらえる。

agent.png

windows 10 の .ssh/config で使えないもの

ControlMaster
ControlPath
ControlPersist
GSSAPIAuthentication

~.conf を結合して config を作る君

sshconfig.sh
set -e
sshconfig() {
    cat *.conf > ../config
}
sshwinconfig() {
    sed \
     -e 's/ProxyCommand ssh /ProxyCommand C:\\a\\OpenSSH-Win64\\ssh.exe /' \
     -e 's/ControlMaster/# ControlMaster/' \
     -e 's/ControlPath/# ControlPath/' \
     -e 's/ControlPersist/# ControlPersist/' \
     -e 's/GSSAPIAuthentication/# GSSAPIAuthentication/' \
     ../config > ../config.win
}
sshconfig
sshwinconfig
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1