在AWS ubuntu服务器下运行的git上的权限被拒绝(公钥)错误

时间:2019-03-07 16:42:12

标签: git ssh

我尝试按照此处编写的方式通过git部署安装Nginx https://devmarketer.io/learn/deploy-laravel-5-app-lemp-stack-ubuntu-nginx/

但在AWS下的Ubuntu下。 在安装过程中,我创建了pem fiel,并使用ssh连接到ubuintu系统。

但是使用命令推送到服务器

root@ec2-NN-NN-NN-NN.us-east-2.compute.amazonaws.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

我遇到错误

package com.firsttest.controller;

import javax.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.firsttest.pojo.SampleRequest;

@RestController
@RequestMapping("/test")
public class FirstTestController {



    @PostMapping("/getBySignatureOne")
    public ResponseEntity<?> getTestString(@Valid @RequestBody SampleRequest sampleRequest) {
        System.out.println("getFromDate : " + sampleRequest.getFromDate());
        System.out.println("getToDate : " + sampleRequest.getToDate());
        return null;//I dont want to send any response.
    }
}

我要采取什么步骤才能使git工作?

谢谢!

1 个答案:

答案 0 :(得分:1)

您必须创建非root用户:

sudo useradd -m nonerootuser

将在/ home /中创建此子目录

从本地服务器复制到/home/nonerootuser/.ssh配置,id_rsa,id_rsa.pub文件。或创建它们

重新启动服务

 service sshd restart

使用git之前,您需要切换到该用户。

su -l  nonerootuser