0

I'm trying to manage my dotfiles and .config directory with git. I create a new repo and run git init. After that I run git add . and git commit -m "first commit" then git remote add origin https://github.com/usename/dotfiles.git. However when I go to push with git push -u origin master I get:

Warning: Permanently added the RSA host key for IP address 'XXX.XX.XXX.X' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

I accidentally deleted my .gitconfig (I'm not sure if that caused this?) but I have made a new one.

Also when I run git add . there is no output.

.gitignore

*
!.config/
.config/**
!.config/bspwm/*
!.config/compton.conf
!.config/htop/*
!.config/mpd/*
!.config/mupen64plus/*
!.config/neofetch/*
!.config/polybar/*
!.config/ranger/*
!.config/sxhkdrc/*

!.scripts/

!.bashrc
!.ncmpcpp
!.vimrc
!.xinitrc
!.Xresources
sorens
  • 4,975
  • 3
  • 29
  • 52
GTA.sprx
  • 817
  • 1
  • 8
  • 24
  • Did you use this exact command exactly as you typed it? `git remote add origin https://github.com/usename/dotfiles.git` Did you change `username` to your Github username? Do you have an existing repository on Github named `dotfiles`? – sorens Jul 14 '20 at 04:32
  • @sorens Yes I just removed my username. I did have a repo called 'dotfiles' however I deleted it and made a new one. This is also happening with a repo I have in a vagrant machine also in my home directory. – GTA.sprx Jul 14 '20 at 04:41
  • Did you put your public key on github? – sensorario Jul 14 '20 at 05:55
  • @sensorario I believe I did while doing some assignments in the vagrant machine. How can I check? – GTA.sprx Jul 14 '20 at 05:57
  • https://stackoverflow.com/search?q=%5Bgit%5D+Permission+denied+publickey – phd Jul 14 '20 at 06:36
  • @GTA.sprx Start debugging with `ssh -Tv git@github.com` – phd Jul 14 '20 at 06:36

1 Answers1

0

Check you local machine's public key:

cat ~/.ssh/id_rsa.pub

You should see something like this:

ssh-rsa AAAAB3NzaCsdfsd9NPghakTk54ykAmOvMwYNyVfB7P4V55wahURuYMDsQX4fEwYDBvQcJN5XFlCrH7KThL106w9yRSrPGUVI4qskm8cUKkW/GfXLIUlcKNKbCTAkldsfgsdfGl6qXZRnsr2oHcfNsl95ADGQEloPJ8h9oGW3Ji6pOz7PiXoNUxcUqsdfgsdyisSRzEB9iqSKRFCNLigeoGCHtxa7mgkBaHag+WQ5OBXmvOsmeOn8eLsMLCo6pk0cuGVAOO8J559/RophirsKuIs5+b6FVovf1dfgsdzXlmTKhU8oMIt16+srIqnUSVSThOnT3Bl21us3qL7lH username@something.local

Then copy this public key and add it to the github configuration. If this answer is not complete I'll edit for better informations about github interface.

If the key is alreasy on github, an alert will notice you that you cant add already present key.

sensorario
  • 20,262
  • 30
  • 97
  • 159