我想在 Windows上的 Ubuntu(即 WSL)上的 bash 中使用 Windowsstart命令。但是,我不能通过简单地输入来使用它start:
nek@NEK:/mnt/c/Users/Nek$ start test.txt
Command 'start' is available in '/sbin/start'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative privileges associated with your user account.
start: command not found
Run Code Online (Sandbox Code Playgroud)
我注意到这start.exe可能不存在。
C:\Users\Nek>where start
INFO: Could not find files for the given pattern(s).
Run Code Online (Sandbox Code Playgroud)
是start内置命令吗?我们可以start在 bash 中使用吗?
我设置了 Windows 10 的 OpenSSH 服务器,通过本文中描述的方法建立到 WSL2 bash 的 ssh 连接:“THE EASY WAY how to SSH into Bash and WSL2 on Windows 10 from an external machine”,以及本文档:“OpenSSH key管理”。
总之,我以管理员身份在 PowerShell 上运行以下命令:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -Force
Run Code Online (Sandbox Code Playgroud)
之后,我可以ssh <my Windows username>@localhost使用 Windows 密码通过 ssh 从 PowerShell 连接到本地主机上的 WSL2 bash。
接下来,我想不使用密码而是使用密钥对进行连接。因此,我在 PowerShell 上创建了一个密钥对并将其定位为C:\Users\<my Windows username>\.ssh\authorized_keys.
cd C:\Users\<my Windows username>\.ssh
ssh-keygen -t ed25519 -f …Run Code Online (Sandbox Code Playgroud)