Differences

This shows you the differences between the selected revisions of the page.

2019-09-06 2019-09-09
no summary (187.189.90.62) powershell example for listing host keys (martin)
Line 42: Line 42:
==== Finding Host Key ==== ==== Finding Host Key ====
-Before the first connection, find out fingerprint of the server's host key by using  ''%%ssh-keygen.exe%%'' from the OpenSSH installation folder (''%WINDIR%\System32\OpenSSH'' or ''C:\Program Files\OpenSSH''), as the Administrator (with PowerShell, use ''$env:ProgramData'' instead of ''%ProgramData%''): &winpath+Before the first connection, find out fingerprint of the server's host key by using  ''%%ssh-keygen.exe%%'' for each file.
-To display all host keys, use this command:+In Windows command-prompt, use:
<code batch> <code batch>
-for %f in (%ProgramData%\ssh\ssh_host_*_key) do .\ssh-keygen.exe -l -f "%f"+for %f in (%ProgramData%\ssh\ssh_host_*_key) do @%WINDIR%\System32\OpenSSH\ssh-keygen.exe -l -f "%f"
 +</code>;
-or +//Replace ''%WINDIR%\System32'' with ''%ProgramFiles%'', if appropriate.// 
- $files= @(Get-childItem $env:ProgramData\ssh\ssh_host_*_key); foreach ($f in $files) { C:\Windows\System32\OpenSSH\ssh-keygen.exe -l -f "$f"}+ 
 +In PowerShell, use
 + 
 +<code powershell
 +Get-ChildItem $env:ProgramData\ssh\ssh_host_*_key | ForEach-Object { . $env:WINDIR\System32\OpenSSH\ssh-keygen.exe -l -f $_ }
</code> </code>
 +
 +//Replace ''$env:WINDIR\System32'' with ''$env:ProgramFiles'', if appropriate.//
You will get an output like this: You will get an output like this:
<code> <code>
-C:\Windows\System32\OpenSSH>for %f in (%ProgramData%\ssh\ssh_host_*_key) do @.\ssh-keygen.exe -l -f "%f"+C:\Windows\System32\OpenSSH>for %f in (%ProgramData%\ssh\ssh_host_*_key) do @%WINDIR%\System32\OpenSSH\ssh-keygen.exe -l -f "%f"
1024 SHA256:K1kYcE7GHAqHLNPBaGVLOYBQif04VLOQN9kDbiLW/eE martin@example (DSA) 1024 SHA256:K1kYcE7GHAqHLNPBaGVLOYBQif04VLOQN9kDbiLW/eE martin@example (DSA)
256 SHA256:7pFXY/Ad3itb6+fLlNwU3zc6X6o/ZmV3/mfyRnE46xg martin@example (ECDSA) 256 SHA256:7pFXY/Ad3itb6+fLlNwU3zc6X6o/ZmV3/mfyRnE46xg martin@example (ECDSA)

Last modified: by martin