Reemh / lunamon

An application that monitors my cat Luna
Mozilla Public License 2.0
0 stars 2 forks source link

How to develop on the PI? #1

Open Reemh opened 4 years ago

Reemh commented 4 years ago

We want a way to be able to develop on my laptop but be able to trigger some CI stuff that publish this code on the PI automatically. A lazy solution would be to push here and pull there but that doesn't sound like a real solution.

thinkh commented 4 years ago

We can try VS Code Remote Development.

thinkh commented 4 years ago

We tried the proposed VS Code Remote Development and it works good. Sometimes there some disconnects, but in general it works good.

thinkh commented 4 years ago

In the following some instructions how to setup and use an SSH key for the VS Code Remote Development (source).

  1. Open Git Bash on your host system (e.g., Windows)
  2. Generate key pair: ssh-keygen -t rsa -b 4096 -f "/c/Users/<USERNAME>/.ssh/lunamon_pi_rsa"
  3. Copy public key to pi: scp /c/Users/<USERNAME>/.ssh/lunamon_pi_rsa.pub pi@<RASPBIAN_IP>:~/key.pub
  4. Login to pi: ssh pi@<RASPBIAN_IP> -> enter pi password
  5. Check if .ssh directory exists: ls .ssh
  6. Copy key to authorized keys: cat ~/key.pub >> ~/.ssh/authorized_keys
  7. Optionally, make read-only: chmod 600 ~/.ssh/authorized_keys
  8. Remove public key: rm ~/key.pub
  9. exit
  10. Try login with ssh key: ssh -i /c/Users/<USERNAME>/.ssh/lunamon_pi_rsa pi@<RASPBIAN_IP>
  11. Create or edit /c/Users/<USERNAME>/.ssh/config with an editor
    Host <RASPBIAN_IP>
     HostName <RASPBIAN_IP>
     User pi
     IdentityFile "~/.ssh/lunamon_pi_rsa"
  12. In VS Code: Add SSH remote host -> select the rasbian ip