Mar*_*way 16 git ssh powershell
试图为我的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
Run Code Online (Sandbox Code Playgroud)
如果我给文件的位置并运行
ssh -vT git@github.com
Run Code Online (Sandbox Code Playgroud)
它不检查要使用的公钥的自定义位置
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).
Run Code Online (Sandbox Code Playgroud)
Sto*_*ica 32
Run Code Online (Sandbox Code Playgroud)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-keygen -t rsa -b 4096 -C "my@emailaddress.com" -f /path/to/key
Run Code Online (Sandbox Code Playgroud)
这将保存您的私钥/path/to/key和公钥/path/to/key.pub.成功后,您将看到以下内容,而不是错误消息:
Run Code Online (Sandbox Code Playgroud)Your identification has been saved in /path/to/key. Your public key has been saved in /path/to/key.pub. The key fingerprint is: 76:f7:82:04:1e:64:eb:9c:df:dc:0a:6b:26:73:1b:2c The key's randomart image is: +--[ RSA 2048]----+ | o | | o . | | + | | + + | | S o . | | . = = o | | E * + o | | o.++ o | | *o.. | +-----------------+
然后,要ssh在自定义位置查找文件,请使用以下-i标志:
ssh -i /path/to/key -vT git@github.com
Run Code Online (Sandbox Code Playgroud)
或者,如果您正在运行身份验证代理,则可以使用以下命令将密钥添加到代理:
ssh-add /path/to/key
Run Code Online (Sandbox Code Playgroud)
代理存储密钥后,您可以执行以下操作:
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
响应应该类似于:
Run Code Online (Sandbox Code Playgroud)Hi USER! You've successfully authenticated, but GitHub does not provide shell access.
您可以继续使用以下命令克隆存储库:
git clone git@github.com:USER/REPO
Run Code Online (Sandbox Code Playgroud)
mbo*_*007 10
对我来说,该ssh-keygen命令似乎仅在使用 cmd 时才会失败:
您的身份信息已保存在 [...]/.ssh/id_rsa 中。fdopen [...]/.ssh/id_rsa.pub 失败:没有这样的文件或目录
生成了私钥,但创建了 0 字节的公钥文件。
如果我在 Windows 上的 Git Bash 中运行该命令,它就会起作用。
| 归档时间: |
|
| 查看次数: |
59813 次 |
| 最近记录: |