Skip to content

Instantly share code, notes, and snippets.

@mocon
Last active May 1, 2019 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mocon/473ef0e59273028dde40a5c743dc1925 to your computer and use it in GitHub Desktop.
Save mocon/473ef0e59273028dde40a5c743dc1925 to your computer and use it in GitHub Desktop.
Install Node.js on Raspberry Pi, set up SSH keys for GitHub, clone the project repo

Install node and npm

wget -O - https://raw.githubusercontent.com/audstanley/NodeJs-Raspberry-Pi/master/Install-Node.sh | sudo bash

Confirm that they are installed

node -v
npm -v

Generate SSH key

ssh-keygen -b 2048 -t rsa

Change to .ssh directory

cd
cd .ssh

Update permissions on SSH key files

touch authorized_keys
sudo chmod 700 ~/.ssh/
sudo chmod 600 ~/.ssh/authorized_keys

Show the public key so you can select it and right-click to Copy it

cat id_rsa.pub

Add it to your GitHub SSH Settings.

Create the Repos directory

cd
cd Documents
mkdir Repos
cd Repos

Set git email and name, to identify your commits

git config --global user.email "myles.oconnor@gmail.com"
git config --global user.name "Myles O'Connor"

Clone the project's code from GitHub to your computer's Repos directory

git clone git@github.com:mocon/pi-a-la-node.git
cd pi-a-la-node

Run the project

npm start

Make terminal aliases so you don't have to type long commands every time

Open your .bashrc file, which holds terminal configuration:

sudo nano ~/.bashrc

Add this line to the top of it:

source ~/.bash_profile

Press Ctrl-O to save the changes, and Ctrl-X to exit the file.

Create your .bash_profile file:

nano ~/.bash_profile

Add the following to it, then save with Ctrl-O, Ctrl-X as before:

alias aliases="nano ~/.bash_profile"
alias k="clear"

alias gs="clear && git branch && git status"
alias gd="git diff"

alias repos="cd ~/Documents/Repos"
alias project="cd ~/Documents/Repos/pi-a-la-node"

Enable SSH access to Raspberry Pi

sudo raspi-config

Select Interfacing Options > SSH > Yes > Ok > Finish.

Connect to the Raspberry Pi via SSH from another device

Assuming your Raspberry Pi hostname is raspberrypi, and your user is the default pi (to check your hostname, go to Raspberry Pi menu in left corner > Preferences > Raspberry Pi Configuration):

ssh pi@raspberrypi.local

You will be asked for your Raspberry Pi password.

Close SSH connection

exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment