Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Git remote tries to connect to my server as my current local user

Git remote tries to connect to my server as my current local user


I am trying to setup my git workflow (to deploy automatically my node.js app when I push). I have tried multiple things and end up doing this :

I managed to make this method work but I have one problem left : I am in the list of authorized_keys of my git and root users so I can login via SSH to these users. But when I do a git pull, my computer tries to ssh using its current user to the Server. That means that it searches on my server a user which has the same login as my local one (which doesn't exist)

If I am logged locally as root, it connect as root to the distant server and works. Otherwise, it tries a user that doesn't exist there and doesn't work.

Not sure if I explained this well... Sorry if this is not. Anyway if anyone know how to fix this and make me able to use git without having to create a distant user for each people of my team it would be cool :) Oh and my client is OS X and server Ubuntu

Problem courtesy of: Malharhak


I’m not entirely sure if I understood you correctly, but you can set the username directly when specifying the URL of the Remote.

For example on most Git hosting sites, you are supposed to use the user git when connecting via SSH. This allows them to create only a single user they have to maintain while putting all authorization details behind that.

So a usual remote URL on GitHub for example looks like this: [email protected]:user/repository. This is the long form of ssh://[email protected]/user/repository.

So when you set your remote, when cloning, or afterwards, just include your username there and Git will use it when connecting via SSH:

git clone [email protected]:/path/to/repository
Solution courtesy of: poke


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Git remote tries to connect to my server as my current local user


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription