推送Gitlab回购时,ssh连接失败 [英] ssh connection failing when pushing on a Gitlab repo

查看:1263
本文介绍了推送Gitlab回购时,ssh连接失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已安装 GitLab 。假设我将它安装在 / home / myuser / gitlab 中。


  1. 新项目

  2. 我被告知要创建一个存放在 / home / myuser / gitlab / test
  3. 我在 /home/myuser/.ssh

  4. 中添加了一些SSH密钥然后我初始化了一个Git在 / home / myuser / gitlab / test

  5. 的回购中,我添加了一个远程 git @ localhost:root / testing.git
    但是当我尝试推送时,我收到以下错误消息:



  $ git push -u origin master 
ssh:连接到主机localhost端口22:连接被拒绝
致命:无法从远程存储库读取。

请确保您拥有正确的访问权限
并存在存储库。

我在OS X中安装了GitLab,并且在 / home中有其他SSH密钥/myhome/.ssh ,我在 /home/myuser/gitlab/.git/config 中设置了用户邮件和名字,将这些全局设置为仅用于测试),并从 / home / myuser / gitlab 启动服务器。如果我运行 ssh git @ localhost ,我会得到 / p>

  /home/myhome/.ssh/config第4行:垃圾在行尾; 家。 

在这个文件中,我为另一个项目设置了远程服务器。我认为这是问题,但我不知道如何解决它。



更新:以下是我的〜/ .git的内容/ config file

 主机remote_test_server 
主机名remote_test_user@ftp.remote_test_server
IdentityFile〜/ .ssh / id_rsa_stf.pub
User< your home acct>


解决方案


/ home / myhome /.ssh/config第4行:垃圾在行尾; home。

这会阻止任何ssh命令正常工作,因为远程会话会产生寄生回声。


  • 检查 .profile 或其他 .rc 文件,并查看是否有任何回应完成。

    或者至少用 ssh -T git @ localhost ,以禁用任何TTY分配。 检查你的 .ssh / config 文件,该文件似乎没有正确格式化。



  • 用户 / code> 应该是在rmeote服务器上用于ssh会话的帐户的登录名。

    它应该不是是homedir路径。

    IdentityFile 应该引用私钥(〜/ .ssh / id_rsa_stf ),不是公共的!



    主机名 应该引用远程服务器' ftp.remote_test_server ',而不是用户@ rem oteServer。


    I have installed GitLab. Suppose I installed it in /home/myuser/gitlab.

    1. I created a new project
    2. I was told to create a repo "test" I put in /home/myuser/gitlab/test
    3. I added some SSH key in /home/myuser/.ssh
    4. Then I initialized a Git repo in /home/myuser/gitlab/test.
    5. Following instructions, I added a remote git@localhost:root/testing.git but when I try to push, I get this error message:

    $ git push -u origin master
    ssh: connect to host localhost port 22: Connection refused
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    I installed GitLab in OS X and I have other SSH keys in /home/myhome/.ssh, I have set up the user email and name inside /home/myuser/gitlab/.git/config, (and set those globally just for testing) and the server is launched from /home/myuser/gitlab. Does anybody have an idea where this error comes from?

    If I run ssh git@localhost, I get

    /home/myhome/.ssh/config line 4: garbage at end of line; "home".
    

    where in this file I have some settings for a remote server for another project. I think it is the problem but I don't really know how to fix it.

    Update : Here's the content of my ~/.git/config file

    Host remote_test_server
    Hostname remote_test_user@ftp.remote_test_server
    IdentityFile ~/.ssh/id_rsa_stf.pub
    User <your home acct>
    

    解决方案

    /home/myhome/.ssh/config line 4: garbage at end of line; "home".

    That would prevent any ssh command to properly function, because of a parasite echo done by the remote session.

    • Check your .profile or other .rc files, and see if any echo is done in those.
      Or at least, test with ssh -T git@localhost, in order to disable any TTY allocation.

    • check also the content of your .ssh/config file, which doesn't seem to be properly formatted.

    See this example of a config file:

    User should be the login name of the account used for the ssh session on the rmeote server.
    It should not be the homedir path.

    IdentityFile should reference the private key (~/.ssh/id_rsa_stf), not the public one!

    Hostname should reference the remote server 'ftp.remote_test_server', not the user@remoteServer.

    这篇关于推送Gitlab回购时,ssh连接失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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