Home Passwordless SSH connect between PC and Linux
Post
Cancel

Passwordless SSH connect between PC and Linux

flowchart LR
    A[local:WindowsPC] <-- git SSH --> B[remote:RaspberryPi]

1. [rpi] create user and password.

1
2
sudo useradd git
sudo passwd git

2. [rpi] visudo, add one line at bottom, and save it.

1
2
3
4
5
6
7
sudo visudo

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

# as user 'git'
su - git

3. [rpi] check git install and make repo root

1
2
3
4
5
6
7
8
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

4. [WindowsPC] make ssh key

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

5. [WindowsPC > rpi] copy the generated public key file

1
2
3
 copy or sftp the generated 'id_rsa.pub' file 
 to raspberrypi 'git'user home '~/' 
 (use WinSCP, sftp etc.)

6. [rpi] login with ‘git’ user

1
2
3
4
5
# if authorized_keys file does not exist, run this.
cat id_rsa.pub > ~/.ssh/authorized_keys

# if authorized_keys file exists already, run this.
cat id_rsa.pub >> ~/.ssh/authorized_keys

7. [WindowsPC] make ssh config for convinent access (passwordless)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# make ssh config file name 'config' like this
c:\Users\user1\.ssh\config

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

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

8. connect SSH

Run like below command in Windows PC on command or terminal or powershell. Passwordless SSH connection is enabled.

1
2
3
WindowsPC> ssh rpigit
#or
WindowsPC> ssh rpipi
This post is licensed under CC BY 4.0 by the author.