1

I have an IP and guest_key from a live linux server.

I am getting error when I try to ssh into the server or use push on it.

Every time I try, I get a Permission denied (publickey) error i

I have tried to push my local Git app into production by ssh like below

git remote add production ssh://root@3******0/var/repo/site.git

how can I add my key to git bash line so that server gives me permission.
I am using windows and git bash for that.

root@**MyIpAdress**: Permission denied (publickey).

Can somebody help me with that: I mean can we directly ssh into live server or just by pushing by Git ?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
mehran
  • 198
  • 3
  • 13
  • 1
    May or may not b a server configuration issue. Try to connect with regular `ssh` to the server. Add `-vv` for more verbose output. You probably also shouldn't use the root account. – Robert May 25 '20 at 16:21

1 Answers1

1

First, it would be really surprising to be using the root account for a remote SSH session.
This is not considered a good practice (since root can do anything), and a service account like "git" (or any regular account you want) is recommended.

Second, you need to add your %USERPROFILE%\.ssh/id_rsa.pub to the remote server ~/.ssh/authorized_keys, in order for any SSH call to have a chance to complete.

If your key is not named id_rsa(.pub), then, as explained here, you need to define an entry (for instance 'xxx') which will reference your actual private key.

Then your URL would be:

cd C:\path\to\repo
git remote set-url production xxx:/var/repo/site.git
git push production master

But again, try and avoid using root on the remote server. (even sudo is dangerous)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250