ユーザ用ツール

サイト用ツール


public:win11_wsl2_ssh_en

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
public:win11_wsl2_ssh_en [2024/03/15 15:56] hirata.nanakopublic:win11_wsl2_ssh_en [2024/03/18 11:12] (現在) – [Generate an SSH Key Pair] hirata.nanako
行 1: 行 1:
-====== WSL SSH In Windows 11 ====== +====== WSL2 SSH In Windows 11 ====== 
 +To access the server of the Space Environment Information Processing System via the Internet, you need to go through a login server (a Jump_Server). The login server is accessed by SSH public key authentication. 
 +In this article, we install Windows Subsystem for Linux 2 (WSL2) on Windows 11 and connect to the login server via SSH. 
 [[https://learn.microsoft.com/en-us/windows/wsl/install|How to install Linux on Windows with WSL (Microsoft)]] [[https://learn.microsoft.com/en-us/windows/wsl/install|How to install Linux on Windows with WSL (Microsoft)]]
  
行 10: 行 11:
  
 ===== Command install ===== ===== Command install =====
 +==== Check OS version ====
 +Start PowerShell or Command Prompt by selecting "Run as administrator". PowerShell or Command Prompt can also be opened in Windows Terminal((Terminal available by default in Windwos 11. Tabs can be used and it is easy to customize. ([[https://learn.microsoft.com/en-us/windows/terminal/|What is Windows Terminal?]] ) )). The command to check the OS version is as follows:
 +
 +<code>
 +PS C:\Windows\System32> winver
 +</code>
 +
 +==== Select and install a Linux distribution ====
 +Linux distributions that install WSL2 online can be found with "wsl -l -o".
 +
 +<code>
 +
 +PS C:\Windows\System32> wsl -l -o
 +The following is a list of valid distributions that can be installed.
 +Install using 'wsl.exe --install <Distro>'.
 +
 +NAME                                   FRIENDLY NAME
 +Ubuntu                                 Ubuntu
 +Debian                                 Debian GNU/Linux
 +kali-linux                             Kali Linux Rolling
 +Ubuntu-18.04                           Ubuntu 18.04 LTS
 +Ubuntu-20.04                           Ubuntu 20.04 LTS
 +Ubuntu-22.04                           Ubuntu 22.04 LTS
 +OracleLinux_7_9                        Oracle Linux 7.9
 +OracleLinux_8_7                        Oracle Linux 8.7
 +OracleLinux_9_1                        Oracle Linux 9.1
 +openSUSE-Leap-15.5                     openSUSE Leap 15.5
 +SUSE-Linux-Enterprise-Server-15-SP4    SUSE Linux Enterprise Server 15 SP4
 +SUSE-Linux-Enterprise-15-SP5           SUSE Linux Enterprise 15 SP5
 +openSUSE-Tumbleweed                    openSUSE Tumbleweed
 +</code>
 +
 +It can also be installed from the Microsoft Store rather than by command.
 +
 +Here we install Ubuntu-22.04({{ :public:win11_wsl2_ssh:wsl_install.jpg?linkonly |}}).
 +
 +<code>
 +wsl --install -d Ubuntu-22.04
 +</code>
 +
 +Reboot the system as instructed.
 +
 +==== Ubuntu Linux startup and initial configuration ====
 +Ubuntu will start automatically after rebooting, but if it does not, start it from the menu. Enter your client username and password.
 +<code>
 +Enter new UNIX username: Local_Username
 +New password:
 +Retype new password:
 +passwd: password updated successfully
 +Installation successful!
 +...
 +
 +</code>
 +
 +Updating Ubuntu.
 +
 +<code>
 +username@localhost:/etc/apt$ sudo apt update
 +username@localhost:/etc/apt$ sudo apt -y full-upgrade
 +</code>
 +
 +Check the timezone and locale, and change them if necessary.
 +<code>
 +username@localhost:/etc/apt$ timedatectl
 +               Local time: Fri 2024-01-12 11:51:24 JST
 +           Universal time: Fri 2024-01-12 02:51:24 UTC
 +                 RTC time: Fri 2024-01-12 02:51:24
 +                Time zone: Asia/Tokyo (JST, +0900)
 +System clock synchronized: yes
 +              NTP service: inactive
 +          RTC in local TZ: no
 +username@localhost:/etc/apt$ localectl status
 +   System Locale: LANG=C.UTF-8
 +       VC Keymap: n/a
 +      X11 Layout: us
 +       X11 Model: pc105
 +</code>
 +
 +===== Generate an SSH Key Pair =====
 +Generate an ssh key in PowerShell. (After # are comments)
 +<code>
 +username@localhost:~$ ssh-keygen -t ecdsa -b 384
 +Generating public/private ecdsa key pair.
 +Enter file in which to save the key (/home/username/.ssh/id_ecdsa):
 +Created directory '/home/username/.ssh'.
 +Enter passphrase (empty for no passphrase):       #Enter passphrase
 +Enter same passphrase again:                      #Enter passphrase
 +Your identification has been saved in /home/username/.ssh/id_ecdsa
 +Your public key has been saved in /home/username/.ssh/id_ecdsa.pub
 +The key fingerprint is:
 +SHA256:qIOIpGWS430BdmS8b+6ARH5JUoLj+eDZ4LD4ux8gEXA username@Win11
 +The key's randomart image is:
 ++---[ECDSA 384]---+
 +|+ E..+           |
 +| =  =.           |
 +|o o= o.          |
 +|.B+ =...         |
 +|XoXo +o S        |
 +|B@o=o..o         |
 +|+o.o+oo          |
 +|  . .o..         |
 +|  o+. ..         |
 ++----[SHA256]-----+
 +</code>
 +
 +===== Apply for a key =====
 +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]]
 + [[http://cidas.isee.nagoya-u.ac.jp/kyodo/regist.shtml.ja|CIDAS System account request]]
 +
 +===== Add your SSH key to the ssh-agent =====
 +Register the created private key with ssh-agent.  (After # are comments)
 +<code>
 +username@localhost:~$ eval $(ssh-agent)                      # Start ssh-agent
 +Agent pid 658
 +username@localhost:~$ ssh-add ~/.ssh/id_ecdsa                # Register private key
 +Enter passphrase for /home/username/.ssh/id_ecdsa:           # pass phrase
 +Identity added: /home/username/.ssh/id_ecdsa (username@Win11)
 +</code>
 +You can check if it is registered with the following command.
 +<code>
 +username@localhost:~$ ssh-add -l
 +384 SHA256:qIOIpGWS430BdmS8b+6ARH5JUoLj+eDZ4LD4ux8gEXA username@Win11 (ECDSA)
 +</code>
 +
 +
 +===== SSH Connection=====
 +Enter the following:\\
 +<code>
 +username@localhost:~$  ssh Jump_Server_Username@Jump_Server -AX
 +The authenticity of host 'Jump_Server' can't be established.
 +ED25519 key fingerprint is SHA256:TTWvEs781VjJwKrzOLJVDtTbLUn/1Ut00as1oihi5QI.
 +This key is not known by any other names
 +Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
 +Warning: Permanently added 'Jump_Server' (ED25519) to the list of known hosts.
 +</code>
 +option -A: Enables forwarding of connections from an authentication agent such as ssh-agent.
 +option -X: Enables X11 forwarding.  
 +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.
 +
 +==== About x11 forwarding ====
 +WSL 2 enables Linux GUI applications to feel native and natural to use on Windows. There is no need to install a new X server.\\
 +[[https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps|Run Linux GUI apps on the Windows Subsystem for Linux]]
 +
 +
 +
  
 +----
 +  * [[public:macos10_openssh|OpenSSH on macOS 10.15]]
public/win11_wsl2_ssh_en.1710485763.txt.gz · 最終更新: 2024/03/15 15:56 by hirata.nanako

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki