I can’t upload files to the repository on github

Asked

Viewed 1,143 times

1

I can’t get access to my repository:

I do the following : I go in the folder and open git bash here

git --global user.name " Di82Rquant"
git --global user.email "[email protected]

git init
 git remote add origin   [email protected]:Di82Rquant/repositorio-teste.git
git pull origin master

of that message :

The Authenticity of host 'github.com (192.30.253.112)' can’t be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue Connecting (yes/no/[fingerprint])? yes Warning: Permanently Added 'github.com,192.30.253.112' (RSA) to the list of known hosts. [email protected]: Permission denied (publickey). fatal: Could not read from remote Repository.

Please make sure you have the correct access Rights and the Repository exists.

git add .
git commit -m " xxxx"

after the :

*** Please Tell me who you are.

Run

git config --global user.email "[email protected]"git config --global user.name "Your Name"

to set your Account’s default Identity. Omit --global to set the Identity only in this Repository.

fatal: Unable to auto-Detect email address (got 'Di82r@Di82rquant. (None)')

git push origin master

error: src refspec master does not match any error: failed to push some refs to '[email protected]:Di82rquant/repositorio-teste.git'

When I give git init it creates a git file in the folder, but it doesn’t recognize my repository.

  • You are sending via ssh, so you need to have generated an ssh-key previously. If you switch to https by changing the origin url to https://github.com/Di82Rquant/repositorio-teste it will ask for the login and password at the time of sending even without need to generate the key.

  • thanks, I did,but unfortunately the patch that github itself gave me didn’t work, when I took the patch straight from the source and put . git worked

1 answer

3

Error: Permission denied (publickey)

An error message "Permission denied" (permission denied) indicates that the server has rejected your connection. There are different reasons for this to happen. The most common examples are described below.

The command sudo should be used with Git?

You should not use the command sudo with Git. If you have a very good reason to use sudo, make sure to use it with all commands (maybe it is best to use su to get a shell as root at that point). If you generate SSH keys without sudo and then try to use a command like sudo git push, you won’t be using the same keys you generated.

Make sure you are connected to the correct server

We know typing is hard. Pay attention to what you type; you won’t be able to connect to "githib.com" or "guthub.com". In some cases, an enterprise network may also cause problems when solving the DNS record.

Enter the second command to confirm that you are connected to the correct domain:

$ ssh -vT [email protected]
> OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
> debug1: Lendo dados de configuração /Users/you/.ssh/config
> debug1: Lendo dados de configuração /etc/ssh_config
> debug1: Solicitando opções para *
> debug1: Conectando a github.com [IP ADDRESS] port 22.

The connection must be made on port 22, unless you are replacing the settings to use SSH on HTTPS port.

Always use the "git user"

All connections must be made as a "git" user, including those for remote Urls. If you try to connect with your Github username, an error will occur:

$ ssh -T [email protected]
> Permissão negada (publickey).

If there is a connection failure when using a remote URL with your Github username, you can change the remote URL for the "git user".

Check your connection by typing:

$ ssh -T [email protected]
> Olá username! Você conseguiu se autenticar...

Make sure you have a key that is in use

  1. Open the terminal.

  2. Make sure you have a private key generated and loaded in SSH. If you are using Openssh 6.7 or earlier

# iniciar o ssh-agent em segundo plano
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add -l
> 2048 a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)

If you are using Openssh 6.8 or later:

# iniciar o ssh-agent em segundo plano
$ eval "$(ssh-agent -s)"
> Agent pid 59566
$ ssh-add -l -E md5
> 2048 MD5:a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/you/.ssh/id_rsa (RSA)

The command ssh-add should print a long string with numbers and letters. If this does not happen, you should generate a new SSH key and associate it with Github.

Tip: In most systems, standard private keys (~/.ssh/id_rsa, ~/.ssh/id_dsa and ~/.ssh/identity) are automatically added to the SSH authentication agent. No need to execute ssh-add path/to/key, unless you replace the name of file when generating a key.

Get more details

You can also check the key being used trying to connect to [email protected]:

$ ssh -vT [email protected]
> ...
> debug1: Arquivo de identificação /Users/you/.ssh/id_rsa type -1
> debug1: Arquivo de identificação /Users/you/.ssh/id_rsa-cert type -1
> debug1: Arquivo de identificação /Users/you/.ssh/id_dsa type -1
> debug1: Arquivo de identificação /Users/you/.ssh/id_dsa-cert type -1
> ...
> debug1: Autenticações que podem prosseguir: publickey
> debug1: Próximo método de autenticação: publickey
> debug1: Tentando chave privada: /Users/you/.ssh/id_rsa
> debug1: Tentando chave privada: /Users/you/.ssh/id_dsa
> debug1: Não há mais métodos de autenticação para tentar.
> Permissão negada (publickey).

In this example, we have no SSH key to use. " -1" at the end of the "identification file" lines indicates that SSH could not find a file to use. Further, the lines "Trying private key" also indicate that the file was not found. If there was a file, the lines would be respectively "1" and "Presenting public key":

$ ssh -vT [email protected]
> ...
> debug1: arquivo de identificação /Users/you/.ssh/id_rsa type 1
> ...
> debug1: Autenticações que podem prosseguir: publickey
> debug1: Próximo método de autenticação: publickey
> debug1: Apresentando chave pública RSA: /Users/you/.ssh/id_rsa

Check that the public key is associated with your account

Provide your public key to Github to establish a secure connection.

  1. Open the terminal.

  2. Start the SSH agent in the background.

$ eval "$(ssh-agent -s)"
> Agent pid 59566
  1. Find and write down the public key fingerprint. If you are using Openssh 6.7 or earlier:

$ ssh-add -l
> 2048 a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/USERNAME/.ssh/id_rsa (RSA)

If you are using Openssh 6.8 or later:

$ ssh-add -l -E md5
> 2048 MD5:a0:dd:42:3c:5a:9d:e4:2a:21:52:4e:78:07:6e:c8:4d /Users/USERNAME/.ssh/id_rsa (RSA)
  1. In the upper right corner of any page, click your profile picture and click Settings.

inserir a descrição da imagem aqui

  1. In the user settings sidebar, click SSH and GPG keys.

inserir a descrição da imagem aqui

  1. Compare the SSH key list with the output of the command ssh-add.

inserir a descrição da imagem aqui

If you can’t see your public key on Github, you’ll need to add the SSH key to Github to associate it to your computer.

Warning: if you find an SSH key that you are not using familiar with Github, delete it immediately and contact Support from Github or Support from Github Premium for help. A unknown public key may indicate a possible problem of security. For more information, see "Review the keys SSH".

Source

https://help.github.com/pt/github/authenticating-to-github/error-permission-denied-publickey

  • thanks, I did,but unfortunately the patch that github itself gave me didn’t work, when I took the patch straight from the source and put . git worked

Browser other questions tagged

You are not signed in. Login or sign up in order to post.