And*_* II 8 git github windows-subsystem-for-linux
我需要运行 Windows 进行视频编辑,但我也做一些编码。Linex 是一头野兽,我希望能够在我的 Windows 计算机上使用 WSL,并且能够从 WSL 执行 ssh。我正在尝试启动一个线程,人们可以在该线程中按照 WSL 和 Github ssh 在 Windows 上的步骤操作。有人可以帮我弄清楚我做错了什么,以便其他人也可以使用 WSL 和 Github 吗?
我的步骤:
sudo apt update && sudo apt upgrade
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
Run Code Online (Sandbox Code Playgroud)
(有没有办法让它自动?)
git config --global core.autocrlf input
Run Code Online (Sandbox Code Playgroud)
Git 仍然有效
dis 这些步骤来共享凭据
Configure the credential manager on Windows by running the following in a Windows command prompt or PowerShell:
git config --global credential.helper wincred
Configure WSL to use the same credential helper, but running the following in a WSL terminal:
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"
Run Code Online (Sandbox Code Playgroud)
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
Git 推送适用于 Windows 端
And*_* II 15
尤里卡我明白了!!
完成上述所有步骤后,进入 Windows 终端并运行:
$ ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
你应该得到:
You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
然后在ubuntu上输入:
$ cd
$ cd .ssh
$ code .
Run Code Online (Sandbox Code Playgroud)
这将在 VS Code 中打开 ubuntu .ssh 文件夹。
然后打开电源外壳并运行:
> cd .ssh
> code .
Run Code Online (Sandbox Code Playgroud)
这将在 VS Code 中打开 Windows .ssh 文件夹。
然后你可以通过 VS Code 将 Windows 文件拖放到 ubuntu。
现在返回 WSL 终端并运行:
$ ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
如果你得到:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0666 for '/home/andre/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/andre/.ssh/id_rsa": bad permissions
git@github.com: Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
然后运行:
$ sudo chmod 600 ~/.ssh/id_rsa
$ sudo chmod 600 ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)
现在当你运行时:
$ ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
你应该得到:
You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
步骤如下:
为此,您可以尝试使用以下命令,
cp -r /mnt/c/Users/<username>/.ssh ~/.ssh
Run Code Online (Sandbox Code Playgroud)
如果目录复制不起作用,那么您也可以尝试复制单个文件。
cp -r /mnt/c/Users/<username>/.ssh/<file-name> ~/.ssh
Run Code Online (Sandbox Code Playgroud)
如果出现权限错误,请将显示错误的文件的权限更改为 600。
chmod 600 ~/.ssh/<file-name>
Run Code Online (Sandbox Code Playgroud)
最后一步应该是以下命令,
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
你现在应该可以走了。
在尝试了许多其他解决方案之后,这对我有用。具体来说,我想我可以使用以下命令从本地 Windows 文件夹复制到 Ubuntu:
cp -r /mnt/c/Users/<username>/.ssh ~/.ssh
但这对我不起作用。只有当我打开 WSL 文件结构时,explorer.exe .
我才看到有两个 .ssh 目录。
打开 Windows 资源管理器后,我将第二个 .ssh 目录中的子文件夹文件移至该目录/home/<username>/.ssh
。然后就成功了。
sam@SAM-SAM:~$ explorer.exe .
sam@SAM-SAM:~$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '140.82.113.4' to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/sam/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "/home/sam/.ssh/id_rsa": bad permissions
git@github.com: Permission denied (publickey).
sam@SAM-SAM:~$ sudo chmod 600 /home/sam/.ssh/id_rsa
[sudo] password for sam:
sam@SAM-SAM:~$ ssh -T git@github.com
Hi foouser! You've successfully authenticated, but GitHub does not provide shell access.
sam@SAM-SAM:~$
Run Code Online (Sandbox Code Playgroud)