This question already has answers here:
Git: How to solve Permission denied (publickey) error when using Git?
(61 answers)
Closed 1 year ago.
I'm trying to git push my app's files, from my computer, to a VPS server running on Ubuntu.
On my computer(windows 10) I did:
git init
git add -A
git commit -m "......"
On the server(in the app's directory):
git init --bare
next did on my computer:
git remote add origin fruitos#
and when I try git push or git pull I get
Permission denied(publickey)
fatal: Could not read from remote repository
I've tried many things so far to solve it but still no solution.
any ideas?
The main goal is to upload the app's file straight from my computer(windows) to the vps server(Ubuntu) using the git push command.
Your git require a ssh-key to secure to communication between your sever and your client you need to take a look how how to setup private and public with this
It's much more easy than you think
Related
I created an application on Heroku. The application is pushed to my git#heroku.com:[My-project-name].git.
I would like to push this application to my own Github account. How can I do it?
By the way, doing:
git clone git#heroku.com:[My-project-name].git
gives back:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
If you're already signed in to Heroku account. Use the following command instead to clone an existing app to your local machine:
heroku git:clone -a your_app_name
cd your_app_name
This will clone your app on your current working directory, and then navigate to your_app_name. Then you can add your github repo's remote by:
git remote add origin url_to_your_github_repo
And finally run the following command to push the code to github:
git push origin master
Every time I want to commit the command "git push heroku master" I am asked in the PowerShell to enter the credentials. When I enter heroku credentials (which is connected to git by default) I get the error message.
But, when I type the credetials contained in the netrc file in my home directory, then the thing functions. The password is however hashed in my opinion. How can I avoid entering credentials every time I want to push changes to git?
UPDATE:
PS C:\Users\Dragan\heroku_workspace\python-getting-started> git push heroku master
github --credentials get: github: command not found
Username for 'https://git.heroku.com': my-email#hotmail.com
Password for 'https://my-email#hotmail.com#git.heroku.com':
github --credentials erase: github: command not found
remote: ! WARNING:
remote: ! Do not authenticate with username and password using git.
remote: ! Run `heroku login` to update your credentials, then retry the git command.
remote: ! See documentation for details: Https://devcenter.heroku.com/articles/http-git#authentication
fatal: Authentication failed for 'https://git.heroku.com/mysterious-river-71834.git/'
A common mistake is cloning using the default (HTTPS) instead of SSH. You can correct this by going to your repository, clicking the ssh button left to the URL field and updating the URL of your origin remote like this:
git remote set-url origin git#github.com:username/repo.git
or if your repository already then click green button CLONE OR DOWNLOAD and select use SSH
Enable SSH authentication
$ heroku create --ssh-git
Redirect tall HTTPS calls to SSH ( If you want to always use SSH Git with Heroku on a particular machine)
$ git config --global url.ssh://git#heroku.com/.insteadOf https://git.heroku.com/
To generate a public key:
ssh-keygen -t rsa Press enter at the first prompt to use the default file location. Next, type a secure passphrase for the key.
If you are using v1.9.3 or later Git for Windows, you can do the following
git config --global credential.helper wincred
Please note that this mechanism stores your username/password in Windows Credential Store.
In relatively newer versions, Git Credential Manager for Windows is bundled with Git for Windows and enabled by default, you might have to override credential.helper configuration for Heroku. GCM seems designed for VSTS and GitHub and I am not how it will behave with other servers.
Worked for me:
Run heroku login using the windows command prompt cmd.exe. This will drop your API key into your _netrc at which point you can open up cygwin or git bash and do whatever you need to
From .gitconfig remove the helper = manager line so that it is no longer registered as a credential helper and stops it from showing up.
(in C:\Users\username\.gitconfig )
Rename _netrc file to .netrc on Windows 7 in the user dir:
cd %home%
REN _netrc .netrc
see:
'git push heroku master' is still asking for authentication
https://github.com/heroku/cli/issues/84#issuecomment-170689175
So I clone a private repo on my VPS using SSH with Git Shell. Now when I commit changes and try to push it to my VPS it says
"Sync failed: The repository doesn't seem to exist anymore. You may not have access, or it may have been deleted or renamed."
Whenever I go into Git Shell and do "git push origin master", I enter my password and it pushes it succesfully.
Why can't I do this through the Github client?
I set up a Debian server that uses SSH for shell access and git repos. I created a bare repo on it and using ssh was able to clone it to my Windows 8 workstation, however when trying to push changes back to the Debian server I get the error depicted here:
Read from remote host 174.52.5.192: Connection reset by peer
fatal: sha1 file '<stdout>' write error: invalid argument
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git#174.52.5.192:/home/git/repos/space-junk.git/'
I use this work station regularly for shell access to the same server via SSH so I know inability to access SSH isn't the problem.
Does anyone have any idea what's going wrong?
Actually, the first push should be:
git push -u origin master
That will link the local branch master to its remote tracking one origin/master
Then, after that first push, you will be able (for all the subsequent push) to do a simple:
git push
See more at "Why do I need to explicitly push a new branch?".
I got it working! It turns out the proper command was
git push origin master
The Windows version didn't have a descriptive enough error message but I got it working by switching over to Linux, which told me my command was wrong.
I know this question has probably been asked a few times but I can't find an exact example of what i'm looking to do and for some reason I can't seem to get it to work.
I have a local ruby on rails repo i'm ready to share with another developer, could someone give me a run through(or point me in the right direction) of creating the new repository by PUSHING my local repo up to it?
Thanks
Marc
I would highly recommend bitbucket (Free up to 5 users) as a hosted git service. They have great documentation:
EDIT:
create repo
https://confluence.atlassian.com/display/BITBUCKET/Create+a+repository
push
https://confluence.atlassian.com/display/BITBUCKET/Import+code+from+an+existing+project
If you want to manage your own remote git repo, then
Make a bare clone of the repo
git clone --bare my_git_project my_git_project.git
Copy the bare repo to remote server
scp -r my_git_project.git gituser#remoteserver.com:/opt/git
Then login to the remote server and go to the git folder
ssh gituser#remoteserver.com
cd /opt/git/my_git_project.git
Then run this command
git init --bare --shared
At this point, any user who has ssh access to the remoteserver.com and write permissions on /opt/git/my_git_project.git will also have push access
A software such as Open source GitlabHQ is highly recommended if you wish to manage your own git hosting. Gitlab also has a hosted version gitlab cloud with unlimited free private repos and unlimited collaborators. Of course they also have paid version.