A
A
Andrey Majidov2018-02-24 18:41:51
git
Andrey Majidov, 2018-02-24 18:41:51

How to work with GIT over SSH on a VPS?

Hello.
Previously used only shared hosting services.
Today I created a VPS droplet on digitalocean, created SSH keys on the laptop and tied the public key to the droplet.
There is a Node.js project on the laptop that needs to be uploaded to this very new droplet.
For test purposes, I created an empty repository on a laptop and an empty repository on a VPS, and I just can’t catch up with how I can push to a VPS or pull from there.
I tried it on laptop

git remote add origin ssh://[email protected]:/projects/project
git push origin master
- got:
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

It is logical that I need to send keys for successful authorization, but I do not understand how to do this.
On the other hand, when connecting to the VPS via PuTTY, where I specify the path to the private key file in the configuration window, the connection to the server is successful, but from there, from the server side, of course, there are no options to pull the project from the laptop.
In general, please tell me how to properly git remote add originover SSH?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Majidov, 2018-02-24
@Famence

Understood. Everything is quite simple.
I enabled authorization to the server with a password, then reset the key pair that I generated when creating the droplet using PuTTY according to the digitalocean manual , after which I generated new keys using another manual from them , in a simpler and more adequate way. I sent them, as written in the manual, to the server, logging in with a password. Now connecting to the server and repository via SSH is successful.
The main thing, which I didn't guess before, is that the keys should be stored in C:\Users\user\.ssh
Now you can disable password authorization.

Z
zooks, 2018-02-24
@zooks

You confused the server key with the repository key.
The repository key must be on the server itself, not on the local computer.

P
Puma Thailand, 2018-02-24
@opium

Especially in any way
Do everything through github
Or raise some kind of your own git server, gitolight or gitlab

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question