Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为git配置SSH密钥以在不在git Bash中时使用_Git_Github_Ssh_Npm_Sublimetext3 - Fatal编程技术网

为git配置SSH密钥以在不在git Bash中时使用

为git配置SSH密钥以在不在git Bash中时使用,git,github,ssh,npm,sublimetext3,Git,Github,Ssh,Npm,Sublimetext3,我是git的新手,除了Windows之外很少使用其他任何东西进行编程 我已经使用设置了一个React应用程序,并将其部署到我的github.io项目页面。我在本地机器上设置了一个SSH密钥,并将其添加到github SSH密钥中。运行ssh-agent和ssh-add可以简化在Git-Bash中的部署,而无需输入用户名和密码。太好了 但是,我在开发中使用了,并且希望使用从编辑器中直接运行npm run deploy。我得到以下错误: Cloning git@github.com:<user

我是git的新手,除了Windows之外很少使用其他任何东西进行编程

我已经使用设置了一个React应用程序,并将其部署到我的github.io项目页面。我在本地机器上设置了一个SSH密钥,并将其添加到github SSH密钥中。运行
ssh-agent
ssh-add
可以简化在Git-Bash中的部署,而无需输入用户名和密码。太好了

但是,我在开发中使用了,并且希望使用从编辑器中直接运行
npm run deploy
。我得到以下错误:

Cloning git@github.com:<username>/<repo>.git into node_modules\gh-pages\.cache
Cloning into 'node_modules\gh-pages\.cache'...
Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
克隆git@github.com:/.git进入节点\u模块\gh页面\缓存
正在克隆到“节点\模块\页面\缓存”。。。
权限被拒绝(公钥)。
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并且存储库存在。

除非我猜错了,否则git似乎不知道如何自动使用SSH密钥,不管它从哪里运行。是否有方法配置此项?

请确保在环境变量中定义:

  • 一个
    路径
    ,其中包括
    /bin
    以及
    /usr/bin
    (带有
    的安装路径)
    usr/bin
    确实包括
    ssh.exe
  • HOME
    环境变量设置为%USERPROFILE%
确保在
dir%HOME%\.ssh


然后从该会话启动SublimiteText。

这主要解决了我的问题。为了使
ssh add
工作,需要设置两个环境变量,当运行
ssh agent-s
时返回这两个环境变量。我猜在Sublime文本中工作的唯一方法是编写一个脚本,从ssh代理中提取这两个值,并在打开Sublime文本之前对它们运行
setx
。有更好的方法吗?@dfoverdx我不知道(如或所示)。但是您需要一个带有密码短语的私钥吗?我没有意识到无密码密钥不需要
ssh-agent
ssl-add
。谢谢你的帮助!