Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.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
如何指定用于PHP Fog上的Git Push的密钥文件?_Php_Git_Ssh_Phpfog - Fatal编程技术网

如何指定用于PHP Fog上的Git Push的密钥文件?

如何指定用于PHP Fog上的Git Push的密钥文件?,php,git,ssh,phpfog,Php,Git,Ssh,Phpfog,以下是我的~/.ssh/config内容 ForwardAgent yes # Default PHP Fog user (name) Host phpfog HostName git01.phpfog.com User git IdentityFile /Users/Pk_2/.ssh/id_rsa_phpfog # Default github Host github.com User git Hostname github.com PreferredAuthentications p

以下是我的~/.ssh/config内容

ForwardAgent yes

# Default PHP Fog user (name)
Host phpfog
HostName git01.phpfog.com
User git
IdentityFile /Users/Pk_2/.ssh/id_rsa_phpfog


# Default github
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile /Users/Pk_2/.ssh/id_rsa
但当我尝试在phpfog repo文件夹上推git时,它会给我

Permission denied(public key)
fatal:the  remote end hung up unexpectedly 
但除非我将id_rsa_phpfog重命名为id_rsa,否则我无法推送到phpfog。那么我可以指定密钥文件吗


PHPFog config-

在我的
~/.ssh/config
文件中,每个“主机”定义中都有一行附加内容:

IdentitiesOnly yes

git可以很好地为不同的主机使用不同的密钥。

在我的
~/.ssh/config
文件中,每个“主机”定义中还有一行:

IdentitiesOnly yes
git可以为不同的主机使用不同的键。您可以使用:

ssh phpfog -vvv
获取ssh尝试连接时的调试输出。如果您使用的是不同的键,您应该看到如下内容

debug1: Reading configuration data /Users/<yourusername>/.ssh/config
debug1: Applying options for phpfog
debug1: Reading configuration data /etc/ssh_config
...
debug1: Offering RSA public key: /Users/<yourusername>/.ssh/id_rsa_phpfog
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1:读取配置数据/Users/.ssh/config
debug1:应用phpfog的选项
debug1:读取配置数据/etc/ssh\u config
...
debug1:提供RSA公钥:/Users/.ssh/id\u RSA\u phpfog
debug3:发送\u pubkey\u测试
debug2:我们发送了一个公钥包,等待回复
如果您没有看到任何提到
id\u rsa\u phpfog
的内容,您可能没有使用在
.ssh/config
文件中定义的主机名,或者该文件不在正确的位置

如果所有这些看起来都是正确的,那么很可能您在phpfog上添加的公钥不正确(与您自己的公钥不完全匹配)

您可以使用:

ssh phpfog -vvv
获取ssh尝试连接时的调试输出。如果您使用的是不同的键,您应该看到如下内容

debug1: Reading configuration data /Users/<yourusername>/.ssh/config
debug1: Applying options for phpfog
debug1: Reading configuration data /etc/ssh_config
...
debug1: Offering RSA public key: /Users/<yourusername>/.ssh/id_rsa_phpfog
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1:读取配置数据/Users/.ssh/config
debug1:应用phpfog的选项
debug1:读取配置数据/etc/ssh\u config
...
debug1:提供RSA公钥:/Users/.ssh/id\u RSA\u phpfog
debug3:发送\u pubkey\u测试
debug2:我们发送了一个公钥包,等待回复
如果您没有看到任何提到
id\u rsa\u phpfog
的内容,您可能没有使用在
.ssh/config
文件中定义的主机名,或者该文件不在正确的位置


如果所有这些看起来都是正确的,那么很可能您在phpfog上添加的公钥不正确(与您自己的公钥不完全匹配)

您的项目的.git/config可能需要编辑,以允许源站使用您在~/.ssh/config中定义的主机

编辑您的
/.git/config
文件

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = <ssh-config-host>:<app_name_here>
或者您也可以使用您定义的主机重新克隆您的应用程序:

git clone phpfog:www.example.com

您的项目的.git/config可能需要编辑,以允许源站使用您在~/.ssh/config中定义的主机

编辑您的
/.git/config
文件

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = <ssh-config-host>:<app_name_here>
或者您也可以使用您定义的主机重新克隆您的应用程序:

git clone phpfog:www.example.com