본문 바로가기
CI CD

Connect git repository via SSH from Windows to RaspberryPi

by publisher 2023. 1. 14.
반응형

RPI: create user and password

sudo useradd git
sudo passwd git

RPI: visudo add last line this and save

sudo visudo

# add a line like this at bottom
%git ALL=(ALL) NOPASSWD: ALL

# as user 'git'
su - git

RPI: check VCS tool git installed and make repo root

git --version
git config -l
mkdir git_repo
cd git_repo
mkdir first.git
cd first.git
git config --global init.defaultBranch main
git init

On WindowsPC

make ssh key

# in command window, if ssh key not exists,
ssh-keygen -t rsa -b 4096

copy public key file 'id_rsa.pub' to raspberrypi's 'git'user's home '~/' with WinSCP or sftp tools


RPI: On raspberrypi, login with 'git' user

# if authorized_keys file does not exist
cat id_rsa.pub > ~/.ssh/authorized_keys
# if authorized_keys file exists already
cat id_rsa.pub >> ~/.ssh/authorized_keys

On WindowsPC

# make ssh config file name 'config' like this
c:\Users\user1\.ssh\config

# in the 'config' file, write like below
Host rpipi
    HostName 70.1.1.10
    Port 22
    User pi
    IdentityFile ~/.ssh/id_rsa

Host rpigit
    HostName 70.1.1.10
    Port 22
    User git
    IdentityFile ~/.ssh/id_rsa

# after finish above, 
# run like below command in command or terminal or powershell window
WindowsPC> ssh rpigit
or
WindowsPC> ssh rpipi

TADA~! you can make ssh connections passwordless, even in git remote connections.

C:\Users\user1>git clone ssh://git@rpigit:/home/git/git_repo/first.git first.git
Cloning into 'first.git'...
warning: You appear to have cloned an empty repository.

반응형

'CI CD' 카테고리의 다른 글

Intellij IDEA shortcuts  (0) 2023.01.11
Editor(Text / Markdown)  (0) 2023.01.11
Databases  (0) 2023.01.11
Tools to draw a diagram  (0) 2023.01.11
eclipse & JDK downloads link  (0) 2023.01.11

댓글