有人知道如何在2019年12月使github ssh在WSL(Linux的Windows子系统)上正确工作

问题描述 投票:0回答:1

我需要运行Windows进行视频编辑,但我还要进行一些编码。 Linex是一只野兽,我希望能够在Windows计算机上使用WSL,并能够从WSL执行ssh。我正在尝试启动一个线程,人们可以在该线程上执行Windows上的WSL和Github ssh步骤。有人可以帮助我弄清楚我做错了什么,以便其他人也可以使用WSL和Github吗?

我的步骤:

  1. 重置窗口
  2. 转到此站点并安装WSLhttps://docs.microsoft.com/en-us/windows/wsl/install-win10我选择了Ubuntu 18.04 LTS:https://www.microsoft.com/en-us/p/ubuntu-1804-lts/9n9tngvndl3q?rtc=1&activetab=pivot:overviewtab
  3. 设置并升级Ubuntu:sudo apt update && sudo apt upgrade
  4. 使用此网站安装的VS Code:https://code.visualstudio.com/docs/remote/wsl
  5. 安装了远程开发包:https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack
  6. 使用默认设置在Windows上设置gitbash
  7. 使用此站点设置git ssh:https://help.github.com/en/github/authenticating-to-github/checking-for-existing-ssh-keys
  8. 一个git clone进行了更改并推送给master只是为了确保一切正常,它可以。
  9. 添加了一个.gitattributes文件以回购
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf

(有没有办法使它自动执行?)

  1. 然后我运行此命令,因为它在网站上建议了它...
git config --global core.autocrlf input
  1. Git仍然有效

  2. 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"
  1. 从wsl和goterror运行git推送:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.      

Please make sure you have the correct access rights
and the repository exists.

Git push在Windows端起作用

git github windows-subsystem-for-linux
1个回答
0
投票

尤里卡我明白了!

完成上述所有步骤后,进入Windows终端并运行:

$ ssh -T [email protected]

您应该得到:

You've successfully authenticated, but GitHub does not provide shell access.

然后在ubuntu上输入:

$ cd
$ cd .ssh 
$ code .

这将在VS代码中打开您的ubuntu .ssh文件夹。

然后打开电源外壳并运行:

> cd .ssh
> code .

这将以VS代码打开Windows .ssh文件夹。

然后您可以通过vs代码将Windows fils拖放到ubuntu。

现在返回您的WSL终端并运行:

$ ssh -T [email protected]

如果得到:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         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
[email protected]: Permission denied (publickey).

然后运行:

$ sudo chmod 600 ~/.ssh/id_rsa
$ sudo chmod 600 ~/.ssh/id_rsa.pub

现在运行时:

$ ssh -T [email protected]

您应该得到:

You've successfully authenticated, but GitHub does not provide shell access.
© www.soinside.com 2019 - 2024. All rights reserved.