【发布时间】:2019-12-20 16:17:10
【问题描述】:
我需要运行 Windows 来进行视频编辑,但我也进行了一些编码。 Linex 是一个野兽,我希望能够在我的 Windows 计算机上使用 WSL,并能够从 WSL 执行 ssh。我正在尝试启动一个线程,人们可以在其中访问并按照 Windows 上的 WSL 和 Github ssh 的步骤进行操作。有人可以帮我找出我做错了什么,以便其他人也可以使用 WSL 和 Github 吗?
我的步骤:
- 重置窗口
- 到这个站点安装 WSL https://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
- 设置和升级 Ubuntu:
sudo apt update && sudo apt upgrade - 使用此网站安装 VS Code:https://code.visualstudio.com/docs/remote/wsl
- 安装了远程开发包:https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack
- 在 Windows 上使用默认设置 gitbash
- 用这个站点设置git ssh:https://help.github.com/en/github/authenticating-to-github/checking-for-existing-ssh-keys
- git clone 是否进行了更改并推送到 master 以确保一切正常,确实如此。
- 添加了一个 .gitattributes 文件到 repo
* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
(有没有办法让它自动化?)
- 然后我运行了这个命令,因为它在网站上建议...
git config --global core.autocrlf input
Git 仍然有效
按这些步骤共享凭据
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"
- 从 wsl 运行 git push 并得到错误:
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.
Git push 在 windows 端工作
【问题讨论】:
-
您在 git bash 中使用的 ssh priv 密钥在 wsl 中不可用。在
~/.ssh/id_rsa中复制它,它应该可以工作 -
并使用
ssh -T git@github.com验证ssh -
如何将其复制到 ~/.ssh/id_rsa?
标签: git github windows-subsystem-for-linux