Corsair
Corsair

Reputation: 1044

Pushing to git repository without SSH key?

I have a personal git server set up for my private projects and created an SSH key on my home machine which was registered on the server. Because I'm currently traveling a lot I cloned some of my repos on my laptop to be able to work on my private projects during my free time. Clonig of these Repos was no problem.

Now I made some changes which are also listed when calling git status. But when I wanted to push the changes I made to my server using the following commands (embedded in a batchfile):

git add * --all
git commit -m "Commit of %fullstamp%"
git push origin master

I only got the following message: Everything up-to-date, altough the password authentication for the remote git user works properly.

By now I think I figured out the reason for this behaviour is the fact, that I forgot to copy the SSH key from my home machine over to my laptop. Now I got two questions:

Upvotes: 3

Views: 23772

Answers (2)

Anjaneyulu Battula
Anjaneyulu Battula

Reputation: 1960

You can do this in other way by using HTTP link. The following are the steps to follow

  • git remote add [shortname] [httpurl]

    shortname - short name for your remoteurl(eg:origin, originhttp ..etc)

    httpurl - here you have to provide your remote http url

  • git push shortname master - use this command to push your code.

    shortname - shortname for your remoteurl

Upvotes: 2

Thilo
Thilo

Reputation: 262842

Yes, it is possible to copy the SSH key to another machine, but yes, you will need the passphrase for it if you protected the key file.

But instead of copying the key, just make a new one on the laptop and add it to the list of authorized keys on the server. That way, you can revoke it if you sell or lose the laptop.

Upvotes: 3

Related Questions