Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.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-Keygen“;没有这样的文件或目录;_Git_Powershell_Ssh - Fatal编程技术网

Git SSH-Keygen“;没有这样的文件或目录;

Git SSH-Keygen“;没有这样的文件或目录;,git,powershell,ssh,Git,Powershell,Ssh,正在尝试为我的git生成公钥。使用Powershell PS>ssh-keygen -t rsa -b 4096 -C "my@emailaddress.com" Generating public/private rsa key pair. Enter file in which to save the key (//.ssh/id_rsa): Could not create directory '//.ssh': Read-only file system Enter passphr

正在尝试为我的git生成公钥。使用Powershell

PS>ssh-keygen -t rsa -b 4096 -C "my@emailaddress.com"
Generating public/private rsa key pair.
Enter file in which to save the key (//.ssh/id_rsa):
Could not create directory '//.ssh': Read-only file system
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Saving key "//.ssh/id_rsa" failed: No such file or directory
如果我给出文件的位置并运行

ssh -vT git@github.com
它不会检查公钥使用的自定义位置

OpenSSH_7.1p1, OpenSSL 1.0.2d 9 Jul 2015
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [<<ANIPADDRESS>>] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:<<SCAREDTOPUBLISH>>
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/id_rsa
debug1: Trying private key: /.ssh/id_dsa
debug1: Trying private key: /.ssh/id_ecdsa
debug1: Trying private key: /.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
OpenSSH_7.1p1,OpenSSL 1.0.2d 2015年7月9日
debug1:读取配置数据/etc/ssh/ssh\u config
debug1:连接到github.com[]端口22。
debug1:已建立连接。
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id\u rsa类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id\u rsa-cert类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id_dsa类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id_dsa-cert类型-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id_ecdsa type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id_ecdsa-cert type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id_ed25519 type-1
debug1:key\u load\u public:没有这样的文件或目录
debug1:identity file/.ssh/id_ed25519-cert type-1
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_7.1
debug1:远程协议版本2.0,远程软件版本libssh-0.7.0
debug1:不匹配:libssh-0.7.0
debug1:正在以“git”身份向github.com:22进行身份验证
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:server->client chacha20-poly1305@openssh.com没有一个
debug1:kex:client->server chacha20-poly1305@openssh.com没有一个
debug1:需要SSH2\u MSG\u KEX\u ECDH\u回复
debug1:服务器主机密钥:ssh rsa SHA256:
debug1:主机“github.com”已知并与RSA主机密钥匹配。
debug1:在/.ssh/known_主机中找到密钥:1
debug1:SSH2\u MSG\u已发送新密钥
debug1:应为SSH2\u MSG\u NEWKEYS
debug1:SSH2\u MSG\u接收到新密钥
debug1:服务器不允许漫游
debug1:SSH2\u消息\u服务\u请求已发送
debug1:SSH2\u消息\u服务\u接收
debug1:可以继续的身份验证:公钥
debug1:下一个身份验证方法:公钥
debug1:正在尝试私钥:/.ssh/id\u rsa
debug1:正在尝试私钥:/.ssh/id\u dsa
debug1:正在尝试私钥:/.ssh/id\u ecdsa
debug1:正在尝试私钥:/.ssh/id_ed25519
debug1:不再尝试验证方法。
权限被拒绝(公钥)。
命令无法保存您的密钥。在具有写访问权限的位置指定文件:

ssh-keygen -t rsa -b 4096 -C "my@emailaddress.com" -f /path/to/key
这将在
/path/to/key
中保存您的私钥,并在
/path/to/key.pub
中保存公钥。 一旦成功, 您将看到如下内容,而不是错误消息:

然后,要使
ssh
在自定义位置查找文件, 使用
-i
标志:

ssh -i /path/to/key -vT git@github.com
或者, 如果正在运行身份验证代理, 您可以通过以下方式将密钥添加到代理:

ssh-add /path/to/key
代理存储密钥后,您只需执行以下操作:

ssh -T git@github.com
响应应该类似于:

您可以继续使用以下工具克隆存储库:

git clone git@github.com:USER/REPO

对我来说,只有在使用cmd时,
ssh-keygen
命令才会失败:

您的身份已保存在[…]/.ssh/id_rsa中。 fdopen[…]/.ssh/id_rsa.pub失败:没有这样的文件或目录

生成私钥,但创建的公钥文件包含0字节


如果我在Windows上的Git Bash中运行该命令,它会工作。

这对我来说是可行的:
ssh add'/home/user/.ssh/id\u rsa'
我收到一个错误:“权限被拒绝的公钥”。您错过了登录Github页面并添加id_rsa.pub密钥的步骤@IgorGanapolsky我不明白这和这个问题有什么关系。我建议问一个新的问题,并确保包括所有必要的细节,如您运行的命令及其完整输出。祝你好运。@IgorGanapolsky这个问题是关于使用
ssh-keygen
命令时“没有这样的文件或目录”的问题。这不是GitHub认证教程,还有很多其他答案,还有GitHub自己的优秀文档。我得到了一个
密钥加载\u public:当它查找
标识文件/home/yuri/.ssh/id\u rsa-cert type-1
时,没有这样的文件或目录
错误。在我的例子中,我尝试将一个相对于我的主目录的路径传递给
~/.ssh/foo
ssh-keygen
,假设用户会得到扩展到我的当前用户,但是,它似乎不支持这一点。将路径更改为绝对
/Users/myuser/.ssh/foo
确实有效。
ssh -T git@github.com
Hi USER! You've successfully authenticated, but GitHub does not provide shell access.
git clone git@github.com:USER/REPO