Previous Topic

Next Topic

Book Contents

Book Index

SSH - 特定のクライアント - Windows 版 OpenSSH

準備

このガイドでは、Windows 版 OpenSSH のコピーが既にインストールされていることを前提としています。

Windows 版 OpenSSH をまだインストールしていない場合は、このクライアントのインストール時に、[Choose Components (コンポーネントの選択)] セクションの [Server (サーバー)] ボックスを必ずチェック解除してください。

手順

  1. OpenSSH の known_hosts および key ファイルを配置するディレクトリ (\Program Files\OpenSSH\bin\ssh など) を選択または作成します。このガイドでは、このディレクトリのことを SSHDIR と呼びます。コマンドで SSHDIR を参照する場合は、実際のディレクトリの値を代入してください。
  2. コマンドプロンプトを開いて、\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_hosts
    sshkeyboy@dotnet.corp.stdnet.com

    Connecting 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)? yes
    Warning: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>

  3. 次のコマンドを実行します。

    ssh-keygen -t rsa

    キーの保存先ファイルを入力するよう求められたら、次の値を指定します。

    SSHDIR\id_rsa

    パスワードの入力を求められたら、Enter キーを押します (確認を求められたら、Enter キーを再び押します)。サーバーの認証に使用する RSA キーが作成されます。ssh-keygen プログラムによってキーファイルに適切なアクセス許可が自動的に与えられます。

    例:

    C:\Program Files\OpenSSH\bin>ssh-keygen -t rsa
    Generating public/private rsa key pair.
    Enter file in which to save the key (P7 $"/.ssh/id_rsa): c:\progra~1\OpenSSH\bin\ssh\id_rsa
    Enter 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@jglshuttle

    C:\Program Files\OpenSSH\bin>

  4. 次のコマンドを実行します。

    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.com
    Connecting to dotnet.corp.stdnet.com...
    sshkeyboy@dotnet.corp.stdnet.com's password:

    (CONTROL+C)

    C:\Program Files\OpenSSH\bin>

  5. 新しいキーのフィンガープリントが MOVEit Transfer ホストに記録されます。Web インターフェイス経由で管理者としてログオンして、ユーザーのプロファイルをクリックして表示し、ユーザーの SSH ポリシーにアクセスし、クライアント キー保留タンクからの SSH キーを受け入れます (キーのフィンガープリントは下図で赤い丸で囲まれています)。

    Embedded OLE File Template, D75, H100

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

    Embedded OLE File Template, D75, H100

    Embedded OLE File Template, D75, H100

  6. 次のコマンドを実行して、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.com
    Connecting to dotnet.corp.stdnet.com...
    sftp> pwd
    Remote working directory: /Home/SSH Key Boy
    sftp> cd ..
    sftp> cd ..
    sftp> dir
    Distribution
    Home
    WebPost
    sftp>

  7. 自動化された設定で SFTP を使用するには、-b コマンドラインオプションを使用して、発行するコマンドのリストを SFTP に提供します。

    :

    C:\>type sftp_commands.txt
    cd /Home/Steve
    put certreq.txt
    dir
    quit

    C:\>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.com
    Connecting to dotnet.corp.stdnet.com...
    sftp> cd /Home/Steve
    sftp> put certreq.txt
    Uploading certreq.txt to /Home/Steve/certreq.txt
    sftp> dir
    DecSet_6858908.exe
    MIFreelyInst_9971297.exe
    brain_1731860.wav
    certreq_1140952.txt
    decryptedFile_5848271.dat
    dmz_backups_2157003.html
    webpost_bundle_4594384.xml
    sftp> quit