両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン |
public:win10_openssh_en [2022/07/06 11:38] – [Apply for a key] hirata.nanako | public:win10_openssh_en [2022/07/06 14:14] (現在) – [File for ssh connection settings] hirata.nanako |
---|
| |
^ ^Host Name^Login Name^ | ^ ^Host Name^Login Name^ |
|Server|Jump Server|Jump Server Username| | |Server|Jump_Server|Jump_Server_Username| |
|Client|Localhost|Local Username| | |Client|Localhost|Local_Username| |
※[[:public:about_pdf|about PDF]] | |
===== Open PowerShell ===== | ===== Open PowerShell ===== |
Press Start and then press {{:public:win10_openssh:powershell.png?linkonly| “Windows PowerShell”}}. \\ | Press Start and then press {{:public:win10_openssh:powershell.png?linkonly| “Windows PowerShell”}}. \\ |
===== Apply for a key ===== | ===== Apply for a key ===== |
Please apply for registration of the created public key id_ecdsa.pub. \\ | Please apply for registration of the created public key id_ecdsa.pub. \\ |
[[https://portal.isee.nagoya-u.ac.jp/iseeadm-bin/acc/skplatform.cgi|isee Jump Server account request] | [[https://portal.isee.nagoya-u.ac.jp/iseeadm-bin/acc/skplatform.cgi|Isee Jump_Server account request]] |
[[http://cidas.isee.nagoya-u.ac.jp/kyodo/regist.shtml.ja|CIDAS System account request]] | [[http://cidas.isee.nagoya-u.ac.jp/kyodo/regist.shtml.ja|CIDAS System account request]] |
| |
===== 鍵の登録 (ssh-agent) ===== | ===== Add your SSH key to the ssh-agent ===== |
{{:public:win10_openssh:fig4.png?160 |}} | {{:public:win10_openssh:fig4.png?160 |}} |
ssh接続でのパスフレーズ入力を省き, ログインサーバ (踏み台サーバ) に秘密鍵を置くのを避けるため, ssh-agentを利用する. \\ | Use ssh-agent to avoid entering the passphrase for ssh connections and to avoid putting the private key on the steppingstone server. \\ |
"スタート" → "Windows管理ツール" → "サービス"で, サービス画面を開く(左図). {{ :public:win10_openssh:fig5.png?linkonly |"OpenSSH Authentication Agent"}}のプロパティを開き, スタートアップの種類は自動を選び, 開始を押し{{ :public:win10_openssh:fig6.png?linkonly |(プロパティ)}}, ssh-agentサービスを起動する. \\ | Select Start > Administrative Tools > Services. Open the properties of the {{ :public:win10_openssh:fig5.png?linkonly |"OpenSSH Authentication Agent"}}. Select automatic as the startup type, press start, and start the ssh-agent service {{ :public:win10_openssh:fig6.png?linkonly | (properties)}}. \\ |
続いて, 秘密鍵 id_ecdsaを登録する. | Next, register the private key id_ecdsa. |
<code> | <code> |
PS C:\> ssh-add 'C:\Users\username\.ssh\id_ecdsa' | PS C:\> ssh-add 'C:\Users\username\.ssh\id_ecdsa' |
Enter passphrase for C:\Users\username\.ssh\id_ecdsa: # パスフレーズ入力 | Enter passphrase for C:\Users\username\.ssh\id_ecdsa: #Enter passphrase |
Identity added: C:\Users\username\.ssh\id_ecdsa (C:\Users\username\.ssh\id_ecdsa) | Identity added: C:\Users\username\.ssh\id_ecdsa (C:\Users\username\.ssh\id_ecdsa) |
</code> | </code> |
登録した鍵は, "ssh-add -l" で確認できる. もし登録した鍵を削除したい場合には "ssh-add -D" で削除する. | The registered key can be checked with "ssh-add -l". If you want to delete a registered key, use "ssh-add -D" to do so. |
| |
===== SSH接続 ===== | ===== SSH Connection ===== |
下記コマンドでssh接続する. -Aオプションは, 認証エージェントを転送する, つまりログインサーバに接続後, 続けて別のサーバに接続する際に, 最初に使った秘密鍵をそのまま使用するためにつける. | Enter the following: |
<code> | <code> |
PS C:\> ssh 踏み台username@踏み台サーバ -A | PS C:\> ssh Jump_Server_Username@Jump_Server -A |
The authenticity of host '踏み台サーバ (***.***.***.***)' can't be established. | The authenticity of host 'Jump_Server (***.***.***.***)' can't be established. |
ECDSA key fingerprint is SHA256:UQwYcMTRGPdEDwQ7y4z5OS+j9PhFpavrKZ3W7jEuH1E. | ECDSA key fingerprint is SHA256:UQwYcMTRGPdEDwQ7y4z5OS+j9PhFpavrKZ3W7jEuH1E. |
Are you sure you want to continue connecting (yes/no)? # yes | Are you sure you want to continue connecting (yes/no)? # yes |
Warning: Permanently added 踏み台サーバ,***.***.***.***' (ECDSA) to the list of known hosts. | Warning: Permanently added Jump_Server,***.***.***.***' (ECDSA) to the list of known hosts. |
| |
</code> | </code> |
| option -A: Enables forwarding of connections from an authentication agent such as ssh-agent.\\ |
| After connecting to the Jump_Server, you can use the same private key that you used at the first connection to connect to another server. |
| ===== x11 forwarding ===== |
| X11 Forwarding is what gives you the ability to use X11 application window on your local host when connecting remotely. \\ |
| First, download and install VcXsrv Windows X Server. \\ |
| [[https://sourceforge.net/projects/vcxsrv/|VcXsrv download]]\\ |
| |
===== X転送 ===== | In the startup screen, proceed with the default settings, and in the final {{ :public:win10_openssh:fig7.png?linkonly | "finish configuration" screen }}, press "save configuration" to save the settings in an appropriate location. The default name of the configuration file is "config.xlaunch". \\ |
リモート接続時に X Window System (X11) を転送して, xアプリケーションウィンドウをローカルホストで利用する. | |
まず, VcXsrv Windows X Server をダウンロードし, インストールする. \\ | |
[[https://sourceforge.net/projects/vcxsrv/|VcXsrv ダウンロード]]\\ | |
| |
起動画面ではデフォルトで進み, 最後の{{ :public:win10_openssh:fig7.png?linkonly |"finish configuration" 画面}}で, "save configuration"を押し, 適当な場所に設定を保存する (設定ファイルのデフォルト名は config.xlaunch). \\ | |
| |
設定ファイルをダブルクリックすることで, VcXsrv Windows X Server が起動するようになるが, 自動起動させるために, スタートアップに登録する. \\ | By double-clicking the configuration file, VcXsrv Windows X Server will start. To make it start automatically, register it to the startup. \\ |
"スタート" → "Windows システムツール" →{{ :public:win10_openssh:fig9.png?linkonly |"ファイル名を指定して実行"}}で, shell:startup と打ち, スタートアップのフォルダを開く. さきほど保存した設定ファイル config.xlaunch をスタートアップフォルダに移動する. \\ | Open Start > Windows system tools > {{ :public:win10_openssh:fig9.png?linkonly | Open Run Command }}, then press "shell:startup". Move the configuration file "config.xlaunch" saved earlier to the startup folder. \\ |
| |
| |
次に, 環境変数DISPLAYを設定する. VcXsrv Windows X Server が起動しているとインジケーターにアイコンが表示されるが, アイコンの上にマウスを乗せると "localhost:0.0 -1 clients" のように表示されるので, この localhost:0.0 を環境変数DISPLAYに設定する. ここでの locaohost 部分は, ローカルのホストネーム, 127.0.0.1, localhost のいずれでもよい. | Next, set the DISPLAY environment variable. When VcXsrv Windows X Server is running, an icon appears in the indicator. When you hover the mouse over the icon, you will see something like "localhost:0.0 -1 clients", so set this localhost:0.0 to the environment variable DISPLAY. The locaohost part here can be either the local hostname, 127.0.0.1, or localhost. |
{{ :public:win10_openssh:fig11.png?direct&200|}} | {{ :public:win10_openssh:fig11.png?direct&200|}} |
| |
PS C:\ [System.Environment]::SetEnvironmentVariable("DISPLAY", "localhost:0.0", "User") | PS C:\ [System.Environment]::SetEnvironmentVariable("DISPLAY", "localhost:0.0", "User") |
</code> | </code> |
PS を再起動し, 設定されているか確認する. | Restart PS and check if it is set. |
<code> | <code> |
PS C:\ $env:DISPLAY | PS C:\ $env:DISPLAY |
</code> | </code> |
| |
x転送を許可するオプションを追加し, ssh接続する. xアプリケーションを起動し, 転送できているかを確認する. | Add the option to allow X-fowarding and make a ssh connection. Start the X11 application and check if the transfer is successful. |
<code> | <code> |
PS C:\ ssh -AXY 踏み台username@踏み台サーバ | PS C:\ ssh -AXY Jump_Server_Username@Jump_Server |
</code> | </code> |
| |
| |
===== ssh接続設定のファイル ===== | ===== File for ssh connection settings ===== |
以上の設定をファイルに保存し (C:\Users\username\.ssh\config), sshコマンドを省略できる. \\ | By saving the ssh configuration to a file (C:\Users\username\.ssh\config), the ssh command can be omitted. |
* IdentityFile は秘密鍵を ssh-agent に登録するため必要ないが, 記録のため記述しておくとよい. | |
<file> | <file> |
Host 踏み台 | Host Jump_Server |
ForwardAgent yes | ForwardAgent yes |
ForwardX11 yes | ForwardX11 yes |
ForwardX11Trusted yes | ForwardX11Trusted yes |
User 踏み台username | User Jump_Server_Username |
HostName 踏み台サーバ | HostName Jump_Server |
IdentityFile "C:\Users\username\.ssh\id_ecdsa" | IdentityFile "C:\Users\username\.ssh\id_ecdsa" |
| |
</file> | </file> |
| |
下記コマンドでssh接続できる. | Connect to ssh with the following: |
<code> | <code> |
PS C:\ ssh 踏み台 | PS C:\ ssh Jump_Server |
</code> | </code> |