git Permission denied (publickey), on every connect

后端 未结 1 422
日久生厌
日久生厌 2021-02-04 20:46

I try to simplify my work with git, then i try to pull my repository with

git pull

i get \"Permission denied (publickey), i solve this by two

相关标签:
1条回答
  • 2021-02-04 21:12

    You should have:

    • an ssh config file specifying all the details of your ssh connection.

      cat ~/.ssh/config
      
      Host yourserver
      Hostname upstream.server.com
      User git                          # or the right user account to use on your server
      IdentityFile /root/.ssh/mykey
      
    • change the remote url

      git remote set-url origin ssh://yourserver:yourRepo.git
      
    • add the agent and ssh-add command in your .bashrc or .profile.

      • One approach is described, for instance, in "Configuring Git over SSH".
      • Another approach in "How to run (git/ssh) authentication agent?"

        1. Add a file called .bashrc to your home folder
        2. Open the file and paste in:

          #! /bin/bash 
          eval `ssh-agent -s` 
          ssh-add /root/.ssh/mykey
          
    0 讨论(0)
提交回复
热议问题