SSH - 特定のクライアント - Windows 版 OpenSSH
- Last Updated: April 28, 2022
- 9 minute read
- MOVEit Transfer
- Version 2022
- Documentation
準備
このガイドでは、Windows 版 OpenSSH のコピーが既にインストールされていることを前提としています。
Windows 版 OpenSSH をまだインストールしていない場合は、このクライアントのインストール時に、[Choose Components (コンポーネントの選択)] セクションの [Server (サーバー)] ボックスを必ずチェック解除してください。
手順
- OpenSSH の known_hosts および key ファイルを配置するディレクトリ (\Program Files\OpenSSH\bin\ssh など) を選択または作成します。このガイドでは、このディレクトリのことを SSHDIR と呼びます。コマンドで SSHDIR を参照する場合は、実際のディレクトリの値を代入してください。
- コマンドプロンプトを開いて、\Program Files\OpenSSH\bin ディレクトリに移動し、次のコマンドを実行します。
sftp -oUserKnownHostsFile=SSHDIR\known_hosts user@hostホストが不明であるという警告が表示されます。質問の答えとして「yes」と入力します。ホストのキーが known_hosts ファイルに追加されます。次に、CONTROL+C キーを押してアプリケーションを終了します。例:
C:\Program Files\OpenSSH\bin>sftp -oUserKnownHostsFile=C:\Progra~1\OpenSSH\bin\ssh\known_hostssshkeyboy@dotnet.corp.stdnet.comConnecting to dotnet.corp.stdnet.com...The authenticity of host 'dotnet.corp.stdnet.com (192.168.3.15)' can't be established.RSA key fingerprint is ce:08:6f:28:87:b6:50:f4:84:e5:37:c2:68:89:33:2a.Are you sure you want to continue connecting (yes/no)? yesWarning:Permanently added 'dotnet.corp.stdnet.com,192.168.3.15' (DSA)to the list of known hosts.sshkeyboy@dotnet.corp.stdnet.com's password:(CONTROL+C)C:\Program Files\OpenSSH\bin> - 次のコマンドを実行します。
ssh-keygen -t rsaキーの保存先ファイルを入力するよう求められたら、次の値を指定します。
SSHDIR\id_rsaパスワードの入力を求められたら、Enter キーを押します (確認を求められたら、Enter キーを再び押します)。サーバーの認証に使用する RSA キーが作成されます。ssh-keygen プログラムによってキーファイルに適切なアクセス許可が自動的に与えられます。例:
C:\Program Files\OpenSSH\bin>ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (P7 quot;/.ssh/id_rsa): c:\progra~1\OpenSSH\bin\ssh\id_rsaEnter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in c:\progra~1\OpenSSH\bin\ssh\id_rsa.Your public key has been saved in c:\progra~1\OpenSSH\bin\ssh\id_rsa.pub.The key fingerprint is:44:a8:8c:88:3f:3f:91:8a:16:07:e4:c6:4a:6e:b8:df xxxx@jglshuttleC:\Program Files\OpenSSH\bin> - 次のコマンドを実行します。
sftp -oUserKnownHostsFile=SSHDIR\known_hosts -oIdentityFile=SSHDIR\id_rsa user@hostユーザーのパスワードの入力を求められます。Control-C キーを押してプログラムを終了します。例:
C:\Program Files\OpenSSH\bin>sftp -oUserKnownHostsFile=c:\progra~1\OpenSSH\bin\ssh\known_hosts -oIdentityFile=c:\progra~1\OpenSSH\bin\ssh\id_rsa sshkeyboy@dotnet.corp.stdnet.comConnecting to dotnet.corp.stdnet.com...sshkeyboy@dotnet.corp.stdnet.com's password:(CONTROL+C)C:\Program Files\OpenSSH\bin> - 新しいキーのフィンガープリントが MOVEit Transfer ホストに記録されます。Web インターフェイス経由で管理者としてログオンして、ユーザーのプロファイルをクリックして表示し、ユーザーの SSH ポリシーにアクセスし、クライアント キー保留タンクからの SSH キーを受け入れます (キーのフィンガープリントは下図で赤い丸で囲まれています)。

ユーザーのプロファイルを開いて、[User Authentication (ユーザー認証)] > [SSH Policy (SSH ポリシー)] > [Current SSH Keys (現在の SSH キー)] でこのフィンガープリントを追加します。適切に設定されたユーザーのプロファイルは次のようになります。


- 次のコマンドを実行して、SFTP を使用して MOVEit Transfer ホストに自動的に接続できるようになりました。
sftp -oUserKnownHostsFile=SSHDIR\known_hosts -oIdentityFile=SSHDIR\id_rsa user@host例:
C:\Program Files\OpenSSH\bin>sftp -oUserKnownHostsFile=c:\progra~1\OpenSSH\bin\ssh\known_hosts -oIdentityFile=c:\progra~1\OpenSSH\bin\ssh\id_rsa sshkeyboy@dotnet.corp.stdnet.comConnecting to dotnet.corp.stdnet.com...sftp> pwdRemote working directory: /Home/SSH Key Boysftp> cd ..sftp> cd ..sftp> dirDistributionHomeWebPostsftp> - 自動化された設定で SFTP を使用するには、-b コマンドラインオプションを使用して、発行するコマンドのリストを SFTP に提供します。例:
C:\>type sftp_commands.txtcd /Home/Steveput certreq.txtdirquitC:\>c:\progra~1\openssh\bin\sftp-oUserKnownHostsFile=c:\progra~1\openssh\bin\ssh\known_hosts -oIdentityFile=c:\progra~1\openssh\bin\ssh\id_rsa -b sftp_commands.txt steve@dotnet.corp.stdnet.comConnecting to dotnet.corp.stdnet.com...sftp> cd /Home/Stevesftp> put certreq.txtUploading certreq.txt to /Home/Steve/certreq.txtsftp> dirDecSet_6858908.exeMIFreelyInst_9971297.exebrain_1731860.wavcertreq_1140952.txtdecryptedFile_5848271.datdmz_backups_2157003.htmlwebpost_bundle_4594384.xmlsftp> quit