Links and tips on how to get a pi set up for developing remotely (#rsyn, #ssh, #mac, #pi)
required (used)
- Raspberry Pi, SD Card, 5V micro-USB
- Macbook Pro w/ ethernet adapter
- WiFi with internet connection
not required
- monitor
- keyboard
- get the latest -lite image from raspberrypi.org
- lite is a smaller bundle without all the GUI components
- flash it on SD card with something like ether
- place a file named
ssh
in the/boot
directory of the SD card 1 2. runtouch /Volumes/boot/ssh
2. this will enable SSH on the pi for one boot, make it count - if you fail just re-add the file for another try
- connect pi via ethernet to macbook
- give the adapter a manual IP address (make sure you don't overlap with the subnet in your wifi network)
- let's try with ip: 192.168.1.222, subnet 255.255.255.0, router: blank
- add a dns record e.g. the main google dns 8.8.8.8
- find the device on the network using
nmap
- run
nmap -p22 --open 192.168.0.0/22
where-p22
only scans for SSH ports and/22
scans for the range192.168.0.0
to192.168.3.255
2. if you can not identify the pi in the found devices try increasing the ip range by further reducing the/22
prefix 2. in my case the pi ends up on192.168.2.3
(dunno why..) - enable internet sharing for the wireless to the ethernet connection
- preferences > sharing > internet sharing 1
# on mac/host machine
cd ~/.ssh
# create new key pair
ssh-keygen -b 4096 -f id_pi -N '' -C 'raspberry pi login key'
# add fingerprint to known hosts
ssh-keyscan -H 192.168.2.3 >> ~/.ssh/known_hosts
# copy public key to pi
ssh-copy-id -i id_pi.pub [email protected]
# you need to enter the password for the pi user which by default is 'raspberry' (we'll fix this later)
The following commands will
- forbid password login on SSH
- change the SSH port 2221
- change the user password interactively
# execute on mac
cd ~/.ssh
# create connection to pi
ssh -i id_pi [email protected]
# change ssh port to 2221
sudo sed -i 's/^#*Port .*/Port 2221/' /etc/ssh/sshd_config
# disable password authentication on ssh
sudo sed -i 's|[#]*PasswordAuthentication yes|PasswordAuthentication no|g' /etc/ssh/sshd_config
# restart ssh service
sudo service ssh restart
# change pi password
passwd # < interactive (make sure to pick an incredibleawesomepipassword 👀)
# re logon
exit
ssh -i id_pi -p 2221 [email protected]
# update packages
sudo apt-get update && apt-get upgrade
sudo apt-get install rsync
- expand filesystem
- set locale
sed -i 's/#*alias ll=.*$/alias ll="ls -ahl"/g' .bashrc
sudo raspi-config
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
source .bashrc
nvm install v7
# add yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
According to the node-serialport docs the ARM platform is partially supported. With node v7.4.0 and serialport v4.0.7 it currently seems to work.
- go into interactive mode with
bluetoothctl
# activate controller
power on
# activate agent
agent on
scan on
# wait....
devices
Backing up a pi config with a mac is explained here
On Mac, you can also use the standard dd tool with a slightly different syntax:
dd if=/dev/rdiskx of=/path/to/image bs=1m
Where /dev/rdiskx is your SD card.
(using rdisk is preferable as its the raw device - quicker)
To find out which disk your device is type diskutil list at a command prompt - also, you may need to be root; to do this type sudo -s and enter your password when prompted.