SlideShare a Scribd company logo
株式会社デバイスドライバーズ
日高亜友
Tips and tricks for WSL
users
- WSL 使いの裏技 その1–
日本を Smart
に!
今回の内容
• WSL の読み方
• WSL の簡単インストール
• WSL へのログイン DO NOT DO 版
• WSL へのログイン The EASY WAY 版
WSL - 何と読むか?
Coolest way to pronounce WSL
(Windows Subsystem for Linux)?
https://www.youtube.com/watch?
v=Ku06yiudHH0
Tips and tricks for WSL users: Two easy and reliable ways to get started with OpenSSL Server
インストール
インストール準備
BIOS の仮想化オプションの有効確認(必須)
Intel: VMX または VTx, VTT, VT-d など
AMD: SVM Mode または AMD-V など
機種毎に異なる
Linux 用 Windows サブシステム有効化
インストール手順
• wsl --list –online リスト確認
• wsl -l –v 状態確認 (よく使う)
• wsl --install Ubuntu-20.04 ( Ubuntu-20.04 の場合 のインストール)
• Windows 再起動
• ユーザー名 と パスワード入力
• wsl --set-default-version 2 デフォルト設定
• wsl --set-default Ubuntu-20.04 デフォルト設定 (忘れがち)
WSL2 のインストール状態
Windows User Account -A
Linux Install-1
Linux Install-2
Linux Install-3
Windows User Account -B
Linux Install-4
Linux Install-5
Linux Install-6
Windows User Account -C
default install
default install
各インストールが
仮想ディスク
ディスク容量圧縮
簡単利用設定
• パスワード無し sudo
visudo コマンド設定
( 前略 )
# User privilege
specification
root ALL=(ALL:ALL)
ALL
# Members of the admin
group may gain root
privileges
%admin ALL=(ALL) ALL
# Allow members of group
sudo to execute any
command
%sudo ALL=(ALL:ALL)
ALL
# See sudoers(5) for more
information on "#include"
( 前略 )
# User privilege
specification
root ALL=(ALL:ALL)
ALL
# Members of the admin
group may gain root
privileges
%admin ALL=(ALL) ALL
# Allow members of group
sudo to execute any
command
%sudo ALL=(ALL:ALL)
ALL
hidaka ALL=NOPASSWD:
ALL
Windows アカウント のセキュリ
ティ
WSL の openssh-server 概要
• WSL インストール済 PC の Linux を
外部からログインしてリモートで利用
• IP アドレスは Windows のもの
• TCP ポートは 22 (ssh) で待ち受け
• Windows から TeraTerm 等で利用可能
使う機会が多い!→2種類の方法
出所: Scott Hanselman Blog
How to SSH into WSL2 on Windows 10 from an external machine
https://www.hanselman.com/blog/how-to-ssh-into-wsl2-on-windows-10-from-an-external-machine
DO NOT DO THE INSTRUCTIONS IN THIS POST ← コメントは後で追加
in July 2020
THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine
https://www.hanselman.com/blog/the-easy-way-how-to-ssh-into-bash-and-wsl2-on-windows-10-from-an-external-machine
in August 2020
WSL2: Windows 10 バージョン 2004
「 Windows 10 20H1 」
DO NOT DO
THE INSTRUCTIONS IN THIS POST 版
DO NOT DO 版 手順
• openssh インストール確認
• sshd_config 設定修正
• ssh ポートリダイレクト設定( Windows )
• ファイアーウォール設定( Windows )
• Linux sshd サービス登録
• 注意: localhost と 127.*.*.* は使えない
DO NOT DO 版機能構成
Windows 内でパケット転送して疑似的に実現
Windows
WSL2
Windows IP / 22 (ssh)
Internal IP / 2222
ssh ポート設定
転送設定
Linux openssh インストール確認
WSL では openssh インストール済 のはず
インストールと Key の確認
# apt install openssh-server
# ls -l
/etc/ssh/ssh_host_ecdsa_key
# ls -l
/etc/ssh/ssh_host_ed25519_key
# ls -l /etc/ssh/ssh_host_rsa_key
Linux sshd_config 設定修正
エディタ で /etc/ssh/sshd_config 編集
( 前略 )
Include
/etc/ssh/sshd_config.d/*.conf
#Port 22
Port 2222
#AddressFamily any
ListenAddress 0.0.0.0
#ListenAddress ::
( 後略 )
( 前略 )
# To disable tunneled clear text
passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
( 後略 )
Windows ssh ポートリダイレクト設定
Windows: 管理権限のコマンドプロンプトで操作
> netsh interface portproxy add v4tov4
listenaddress=0.0.0.0
listenport=22 connectaddress=127.0.0.1
connectport=2222
Windows ファイアーウォール設
定
Windows: 管理権限の PowerShell で操作
> New-NetFireWallRule -DisplayName 'WSL 2 Firewall
Unlock’
-Direction Inbound -LocalPort 22 -Action Allow -
Protocol TCP
> New-NetFireWallRule -DisplayName 'WSL 2 Firewall
Unlock’
-Direction Outbound -LocalPort 22 -Action Allow -
Protocol TCP
sshd スタート設定
# systemctl enable ssh
# service ssh start
# service ssh status running を確認
THE EASY WAY
how to SSH into Bash 版
THE EASY WAY 版 手順
• OpenSSH 設定確認
• sshd 起動・設定
• bash.exe shell 設定
• localhost と 127.*.*.* も使える
• Windows パスワードは必須
THE EASY WAY 版機能構成
Windows 内でパケット転送して疑似的に実現
Windows
WSL2
Windows IP / 22 (ssh)
bash.exe
OpenSSH サービス
Windows sshd 起動とサービス登録
• 確認 ( 以降すべて管理権限の PowerShell)
> Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'
• 有効化
> Add-WindowsCapability -Online -Name
OpenSSH.Server~~~~0.0.1.0
• 起動設定
> Start-Service sshd
> Get-Service sshd
> Set-Service -Name sshd -StartupType 'Automatic’
• シェル設定 ( 設定しないと PowerShell となる)
> New-ItemProperty -Path "HKLM:SOFTWAREOpenSSH" -Name
DefaultShell
完了!
THE EASY WAY how to SSH into
Bash and WSL2 on Windows 10
from an external machine
比較
DO NOT DO 版 THE EASY WAY 版
Scott’s Recommend No Yes
Linux 用 Windows サブシステム 不要 必要
OpenSSH パッケージ openssh-server (Linux) OpenSSH.Server~~~~0.0.1.0
認証管理 Linux Windows
Shell (BASH) /usr/bin/bash C:Windowssystem32Bash.exe
Packer Transfer Yes No
localhost 利用 No Yes
WSL 自動起動 No Yes
ファイアーウォール設定 Yes No
インターネット記事 多い 日本語記事は無い?
トラブル 多い(動作しない) 少ない
まとめ
• WSL の読み方
• WSL の簡単インストール
• WSL へのログイン DO NOT DO 版
• WSL へのログイン The EASY WAY 版
ありがとうございました。
チャンネル登録、いいね ボタン、よろしくお願いします
日本を Smart に!資料 https://www.slideshare.net/
NETMF/

More Related Content

PDF
余ったPCをルータに変える、ソフトウェアルータ「SEIL/x86」
 
PPTX
サーバ脆弱性スキャナ Vuls を OpenStack 環境で使ってみた
PDF
SQL Server エンジニア のための コンテナ入門
PDF
SQL Server エンジニアのためのコンテナ入門
PDF
BHyVeってなんや
PDF
AWS Black Belt Techシリーズ AWS Command Line Interface
PDF
Azure CLI あずにゃんの CLI を使ってみた結果www
PPTX
OpenStackで始めるクラウド環境構築入門
余ったPCをルータに変える、ソフトウェアルータ「SEIL/x86」
 
サーバ脆弱性スキャナ Vuls を OpenStack 環境で使ってみた
SQL Server エンジニア のための コンテナ入門
SQL Server エンジニアのためのコンテナ入門
BHyVeってなんや
AWS Black Belt Techシリーズ AWS Command Line Interface
Azure CLI あずにゃんの CLI を使ってみた結果www
OpenStackで始めるクラウド環境構築入門

Similar to Tips and tricks for WSL users: Two easy and reliable ways to get started with OpenSSL Server (20)

PPTX
OpenStackで始めるクラウド環境構築入門
PDF
自分色のLinuxホームサーバーを作ってみよう
PDF
OpenStackトラブルシューティング入門
PDF
Version管理 1
PDF
Inside wsl
KEY
物理マシンをケチる技術
PPTX
Inside wsl
PPTX
20230128.pptx
PDF
Eucalyptus on OpenStack
PDF
超簡単!Subversion入門 準備編
PDF
VM ロールで仮想デスクトップ環を作ってみよう
PDF
Pycon APAC 2013 Windows Azure Session
PPTX
第一回コンテナ情報交換会@関西
PDF
OpenStackで始めるクラウド環境構築入門
PDF
OpenStack構築手順書 Juno版
PDF
Ansible 2.0 のサマライズとこれから
PDF
OpenStack検証環境構築・トラブルシューティング入門 - OpenStack最新情報セミナー 2014年8月
PPT
DevCloud Installation and Some Hack
PPTX
勉強会0614 vagrant
PDF
Open-FCoE_osc2011tokyofall_20111119
OpenStackで始めるクラウド環境構築入門
自分色のLinuxホームサーバーを作ってみよう
OpenStackトラブルシューティング入門
Version管理 1
Inside wsl
物理マシンをケチる技術
Inside wsl
20230128.pptx
Eucalyptus on OpenStack
超簡単!Subversion入門 準備編
VM ロールで仮想デスクトップ環を作ってみよう
Pycon APAC 2013 Windows Azure Session
第一回コンテナ情報交換会@関西
OpenStackで始めるクラウド環境構築入門
OpenStack構築手順書 Juno版
Ansible 2.0 のサマライズとこれから
OpenStack検証環境構築・トラブルシューティング入門 - OpenStack最新情報セミナー 2014年8月
DevCloud Installation and Some Hack
勉強会0614 vagrant
Open-FCoE_osc2011tokyofall_20111119
Ad

More from Atomu Hidaka (20)

PPTX
Guidance for beginners and experts on how to set up a Windows driver developm...
PPTX
What the end of support of Windows 10 will mean?
PPTX
Explains how to use USBView, which is useful for analyzing Windows USB problems
PPTX
Explaining how to use MBR2GPT in preparation for the end of Windows 10 support
PPTX
The requirements for installing Windows 11 on older PCs have been relaxed.
PPTX
EnOcean-iot, Generative-AI, and RAG for LLM
PPTX
Introduction to the Thunder Cloud Project Technical Committee
PPTX
WSL for IoT, Microcomputer, and Yocto Project
PPTX
Customize Chat-GPT using Azure OpenAI Studio
PPTX
Useful Tips and Tricks for Windows 11 TPM Part 2
PPTX
How to use EnOcean Gateway with Azure OpenAI
PPTX
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
PPTX
Tips and Tricks for developing Windows APO drivers
PPTX
Useful Tips and Tricks for Windows 11 TPM
PPTX
Develop Windows 11 drivers with GitHub Copilot's AI capabilities
PDF
Windows 11 22H2 Feature-Update, Copilot, and Tips
PPTX
Windows 11 information that can be used at the development site
PPTX
ChatGPT solution with EnOcean Gateway
PPTX
Windows ChatGPT Bing AI
PPTX
Windows ChatGPT Bing AI.pptx
Guidance for beginners and experts on how to set up a Windows driver developm...
What the end of support of Windows 10 will mean?
Explains how to use USBView, which is useful for analyzing Windows USB problems
Explaining how to use MBR2GPT in preparation for the end of Windows 10 support
The requirements for installing Windows 11 on older PCs have been relaxed.
EnOcean-iot, Generative-AI, and RAG for LLM
Introduction to the Thunder Cloud Project Technical Committee
WSL for IoT, Microcomputer, and Yocto Project
Customize Chat-GPT using Azure OpenAI Studio
Useful Tips and Tricks for Windows 11 TPM Part 2
How to use EnOcean Gateway with Azure OpenAI
IoT in the era of generative AI, Thanks IoT ALGYAN.pptx
Tips and Tricks for developing Windows APO drivers
Useful Tips and Tricks for Windows 11 TPM
Develop Windows 11 drivers with GitHub Copilot's AI capabilities
Windows 11 22H2 Feature-Update, Copilot, and Tips
Windows 11 information that can be used at the development site
ChatGPT solution with EnOcean Gateway
Windows ChatGPT Bing AI
Windows ChatGPT Bing AI.pptx
Ad

Tips and tricks for WSL users: Two easy and reliable ways to get started with OpenSSL Server

  • 1. 株式会社デバイスドライバーズ 日高亜友 Tips and tricks for WSL users - WSL 使いの裏技 その1– 日本を Smart に!
  • 2. 今回の内容 • WSL の読み方 • WSL の簡単インストール • WSL へのログイン DO NOT DO 版 • WSL へのログイン The EASY WAY 版
  • 3. WSL - 何と読むか? Coolest way to pronounce WSL (Windows Subsystem for Linux)? https://www.youtube.com/watch? v=Ku06yiudHH0
  • 6. インストール準備 BIOS の仮想化オプションの有効確認(必須) Intel: VMX または VTx, VTT, VT-d など AMD: SVM Mode または AMD-V など 機種毎に異なる Linux 用 Windows サブシステム有効化
  • 7. インストール手順 • wsl --list –online リスト確認 • wsl -l –v 状態確認 (よく使う) • wsl --install Ubuntu-20.04 ( Ubuntu-20.04 の場合 のインストール) • Windows 再起動 • ユーザー名 と パスワード入力 • wsl --set-default-version 2 デフォルト設定 • wsl --set-default Ubuntu-20.04 デフォルト設定 (忘れがち)
  • 8. WSL2 のインストール状態 Windows User Account -A Linux Install-1 Linux Install-2 Linux Install-3 Windows User Account -B Linux Install-4 Linux Install-5 Linux Install-6 Windows User Account -C default install default install 各インストールが 仮想ディスク ディスク容量圧縮
  • 9. 簡単利用設定 • パスワード無し sudo visudo コマンド設定 ( 前略 ) # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # See sudoers(5) for more information on "#include" ( 前略 ) # User privilege specification root ALL=(ALL:ALL) ALL # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL hidaka ALL=NOPASSWD: ALL Windows アカウント のセキュリ ティ
  • 10. WSL の openssh-server 概要 • WSL インストール済 PC の Linux を 外部からログインしてリモートで利用 • IP アドレスは Windows のもの • TCP ポートは 22 (ssh) で待ち受け • Windows から TeraTerm 等で利用可能 使う機会が多い!→2種類の方法
  • 11. 出所: Scott Hanselman Blog How to SSH into WSL2 on Windows 10 from an external machine https://www.hanselman.com/blog/how-to-ssh-into-wsl2-on-windows-10-from-an-external-machine DO NOT DO THE INSTRUCTIONS IN THIS POST ← コメントは後で追加 in July 2020 THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine https://www.hanselman.com/blog/the-easy-way-how-to-ssh-into-bash-and-wsl2-on-windows-10-from-an-external-machine in August 2020 WSL2: Windows 10 バージョン 2004 「 Windows 10 20H1 」
  • 12. DO NOT DO THE INSTRUCTIONS IN THIS POST 版
  • 13. DO NOT DO 版 手順 • openssh インストール確認 • sshd_config 設定修正 • ssh ポートリダイレクト設定( Windows ) • ファイアーウォール設定( Windows ) • Linux sshd サービス登録 • 注意: localhost と 127.*.*.* は使えない
  • 14. DO NOT DO 版機能構成 Windows 内でパケット転送して疑似的に実現 Windows WSL2 Windows IP / 22 (ssh) Internal IP / 2222 ssh ポート設定 転送設定
  • 15. Linux openssh インストール確認 WSL では openssh インストール済 のはず インストールと Key の確認 # apt install openssh-server # ls -l /etc/ssh/ssh_host_ecdsa_key # ls -l /etc/ssh/ssh_host_ed25519_key # ls -l /etc/ssh/ssh_host_rsa_key
  • 16. Linux sshd_config 設定修正 エディタ で /etc/ssh/sshd_config 編集 ( 前略 ) Include /etc/ssh/sshd_config.d/*.conf #Port 22 Port 2222 #AddressFamily any ListenAddress 0.0.0.0 #ListenAddress :: ( 後略 ) ( 前略 ) # To disable tunneled clear text passwords, change to no here! PasswordAuthentication yes #PermitEmptyPasswords no ( 後略 )
  • 17. Windows ssh ポートリダイレクト設定 Windows: 管理権限のコマンドプロンプトで操作 > netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=22 connectaddress=127.0.0.1 connectport=2222
  • 18. Windows ファイアーウォール設 定 Windows: 管理権限の PowerShell で操作 > New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock’ -Direction Inbound -LocalPort 22 -Action Allow - Protocol TCP > New-NetFireWallRule -DisplayName 'WSL 2 Firewall Unlock’ -Direction Outbound -LocalPort 22 -Action Allow - Protocol TCP
  • 19. sshd スタート設定 # systemctl enable ssh # service ssh start # service ssh status running を確認
  • 20. THE EASY WAY how to SSH into Bash 版
  • 21. THE EASY WAY 版 手順 • OpenSSH 設定確認 • sshd 起動・設定 • bash.exe shell 設定 • localhost と 127.*.*.* も使える • Windows パスワードは必須
  • 22. THE EASY WAY 版機能構成 Windows 内でパケット転送して疑似的に実現 Windows WSL2 Windows IP / 22 (ssh) bash.exe OpenSSH サービス
  • 23. Windows sshd 起動とサービス登録 • 確認 ( 以降すべて管理権限の PowerShell) > Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' • 有効化 > Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 • 起動設定 > Start-Service sshd > Get-Service sshd > Set-Service -Name sshd -StartupType 'Automatic’ • シェル設定 ( 設定しないと PowerShell となる) > New-ItemProperty -Path "HKLM:SOFTWAREOpenSSH" -Name DefaultShell
  • 24. 完了! THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine
  • 25. 比較 DO NOT DO 版 THE EASY WAY 版 Scott’s Recommend No Yes Linux 用 Windows サブシステム 不要 必要 OpenSSH パッケージ openssh-server (Linux) OpenSSH.Server~~~~0.0.1.0 認証管理 Linux Windows Shell (BASH) /usr/bin/bash C:Windowssystem32Bash.exe Packer Transfer Yes No localhost 利用 No Yes WSL 自動起動 No Yes ファイアーウォール設定 Yes No インターネット記事 多い 日本語記事は無い? トラブル 多い(動作しない) 少ない
  • 26. まとめ • WSL の読み方 • WSL の簡単インストール • WSL へのログイン DO NOT DO 版 • WSL へのログイン The EASY WAY 版