Install Linux development environment in Windows 10
Install Linux development environment in Windows 10¶
Click the "Setting" item.
Click the "Apps" item.
Choice the "Programs and Features".
Click the "Turn Windows features on or off" of the hyperlink.
Check the "Windows Subsystem for Linux" item. We need the feature.
Since WSL 1 Upgrade to WSL 2¶
Using administrator opens PowerShell and executes.
PowerShell
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
TIPs
Upgrade WSL 2
You have to according to the below rules, and then you can upgrade WSL 2.
- Windows 10 (Version 1903 or higher, Build version 18362 or x64 or higher)
- If you use version 1903 or 1909 of Windows 10. Please make sure the Build version is 1049 or higher. Please refer to the Microsoft website.
- The version is 2004 or higher and the Build version is 19041 or suits the ARM64 system.
- Please notice, if your Windows 10 is 1903 or 1909, then you have to you can restore utility. You can find it on the Microsoft website.
- When you want to check your version of Windows. Please choose the "Windows flag key + R", and input "winver", press "Enter". Or you can in the command prompt and input "ver" command, press "Enter". Please upgrade your Windows 10, when your Build version is lower than 18361.
Enable "Virtual Machine Platform" Component
Install WS 2 before, you have to enable the "Virtual Machine Platform" feature, and using the administrator opens PowerShell and execute.
PowerShell
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Restart your computer for complete WSL2 of installing.
Setup WSL 2 to Default Version
Install new Linux before, using the administrator opens PowerShell and execute as below command. Let WSL 2 become to the default version.
PowerShell
wsl --set-default-version 2
The message is "For information on key differences with WSL 2 please visit https://aka.ms/wsl2".
This means "Your system is all set, proceed with the following instructions here.".
Your system is ready, keep going then next command.
Notice
If the message appears "WSL 2 requires an update to its kernel component. For information please visit https://aka.ms/wsl2kernel." Please follow the hyperlink "https://aka.ms/wsl2kernel". And download the setup file (MSI format), install it.
The Linux kernel prepared in your computer for WSL 2. After, please run the command again. It should smoothly complete.
Manually Update the WSL 2 Linux Core
Tips
If the installer cannot find WSL 1, please uninstall the installer, and then run the install again.
Download Linux Core Update Package
Please download the latest WSL2 Linux core update kit (for x64 computers).
Tips
If you are using an ARM64 computer, please change to Download ARM64 Kit.
Install Ubuntu from the Microsoft Store¶
Search for the keyword "Linux", there will be many versions of Linux, select "Ubuntu" here.
Install the Linux distribution of your choice
The following link will open the Microsoft Store page for each distribution package:
Ubuntu 16.04 LTS
Ubuntu 18.04 LTS
Ubuntu 20.04 LTS
openSUSE Leap 15.1
SUSE Linux Enterprise Server 12 SP5
SUSE Linux Enterprise Server 15 SP1
Kali Linux
Debian GNU/Linux
適用於 WSL 的 Fedora Remix
Pengwin
Pengwin Enterprise
Alpine WSL
Start Ubuntu after install complete.
It needs initial a few minutes then the first will begin the system.
The First time login into the system, the system will ask for your username and password. Once, your setup is done. Then you will see the login menu.
Config the password of root
Command-line is "sudo passwd", then into config the password of root.
Excute
sudo apt update
Excute
apt list --upgradable
Install SSH on the Ubuntu¶
Excute
sudo ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
Excute
sudo ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
Excute
sudo chmod 600 /etc/ssh/ssh_host_dsa_key
sudo chmod 600 /etc/ssh/ssh_host_rsa_key
Excute
sudo apt-get install ssh
Excute
sudo nano /etc/ssh/sshd_config
Fix /etc/ssh/sshd-config File
- PermitRootLogin: no => yes
- PubkeyAuthentication: yes => no
- AuthorizedKeysFile .ssh/authorized_keys: remark this line, add # in the advance.
- PasswordAuthentication: no => yes
- It is also not necessary to enter yes in the authorization, but the local configuration needs to be modified.
- /etc/ssh/ssh_config: StrictHostKeyChecking ask => StrictHostKeyChecking no
Excute
sudo /etc/init.d/ssh restart
Excute
sudo ssh -i key root@localhost
Excute
sudo apt install net-tools
Install ifconfig
Excute
ifconfig
Remember the IP address of inet, this is the address to be connected by Windows.
Here is to use "PuTTY" as the connection tool.
The download URL is PuTTY
Ask if the key is accepted as a trust, click "Yes".
Successfully logged in to "Ubuntu on WSL 2" from "PuTTY" of "Windows".
Troubleshooting¶
Permanently added (RSA) to the list of known hosts problem solving for ssh login in linux
- [root@www]# ssh admin@xxx.xxx.xxx.xxx
- The authenticity of host 'xxx.xxx.xxx.xxx can't be established.
- RSA key fingerprint is f4:d0:1a:9c:09:65:78:71:25:33:79:c2:d5:aa:0b:c1.
- Are you sure you want to continue connecting (yes/no)? no
- Host key verification failed.
- [root@www]#
If you enter yes directly, there is no problem
- [root@www]# ssh admin@xxx.xxx.xxx.xx
- The authenticity of host 'xxx.xxx.xxx.xxx' can't be established.
- RSA key fingerprint is f4:d0:1a:9c:09:65:78:71:25:33:79:c2:d5:aa:0b:c1.
- Are you sure you want to continue connecting (yes/no)? yes
- Warning: Permanently added 'xxx.xxx.xxx.xxx' (RSA) to the list of known hosts.
- Permission denied (publickey,gssapi-with-mic,password).
- [root@www]#
If I enter no, then what can I do?
Solving Way
- Delete the ~/.ssh/known_hosts file.
- Fix /etc/ssh/sshd-config file,
PermitRootLogin: no => yes,
PubkeyAuthentication: yes => no,
AuthorizedKeysFile .ssh/authorized_keys: remark this line, add # in the advance.
PasswordAuthentication: no => yes
- Another Way:
Excute: ssh -l username hostname
Ex. ssh -l root localhost
- Are you sure you want to continue connecting (yes/no)?
This is an RSA certification for ssh security certification. You must select yes here to connect.
After the first yes, it will ask you whether to add this RSA authentication to the local permanently. After selecting yes, there will be no reminders in the future.
- You only need to enter the password each time you log in.
- It is also not necessary to enter yes in 1st method, but the local configuration needs to be modified.
- /etc/ssh/ssh_config: StrictHostKeyChecking ask => StrictHostKeyChecking no
Comments
Post a Comment