github - 便携版git(即安装在U盘上的版本)如何设置ssh私钥?

查看:166
本文介绍了github - 便携版git(即安装在U盘上的版本)如何设置ssh私钥?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

便携版的git是即插即用的,可以在任意一台没有安装git的电脑上使用。如果采用和桌面版git相同的方法设置ssh私钥,是无法正常使用ssh访问github远程仓库的,即使我将私钥保存在U盘上。下面是错误信息:

The authenticity of host 'github.com (192.30.253.112)' can't be
established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of know
n hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

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

我想知道如何在便携版的git如何设置ssh私钥才能保证我正常连接远程仓库。

解决方案

我根据git移动版中的readme文件找到了配置方法。其实方法很简单,配置步骤和桌面版git配置ssh-key的方法基本一样,只是其中选择密钥的存放路径这一步有所不同——不要回车使用默认路径,要将路径改为U盘中移动版git的路径(如g:\\git_portable\\.ssh)。然后,每次使用git(移动版)的时候,先使用export HOME=g:\\git_portable临时修改HOME环境变量,其中后面的移动版git的安装路径要根据你的实际情况设置。
这样你就可以像在桌面版git中一样,来使用ssh来访问你的github远程仓库了。
注意,不要忽略上面路径中的的双斜杠\\。

这篇关于github - 便携版git(即安装在U盘上的版本)如何设置ssh私钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆