On local machine:
ssh-keygen -t rsa -b 2048 -C "my raspberry pi server" -f ~/.ssh/myserver
Press enter when asked to enter passphrase. Keep it blank.
Add the following to your local machine's ~/.ssh/config
file
Host myserver
User p1c.ash.e3
Hostname p1cashe3
UpdateHostKeys yes
IdentityFile ~/.ssh/myserver
Copy it to the server
ssh-copy-id -i ~/.ssh/myserver.pub p1c.ash.e3@p1cashe3
Enter password when prompted.
Now login using SSH to server. Now we don't need to specify full username and hostname. It is already specified in ~/.ssh/config
ssh myserver
On server:
sudo vim /etc/ssh/sshd_config
Change some of the lines as below:
PermitRootLogin no
PasswordAuthentication no
Restart SSH service:
sudo systemctl restart ssh
On server
- Update sudeors
Enter the following
sudo visudo -f /etc/sudoers.d/p1cashe3
Defaults insults p1c.ash.e3 ALL = PASSWD: /usr/bin/su
- Comment out other files.
sudo mv /etc/sudoers.d/010_pi-nopasswd /etc/sudoers.d/.010_pi-nopasswd # raspberry pi os sudo mv /etc/sudoers.d/90-cloud-init-users /etc/sudoers.d/.90-cloud-init-users # ubuntu server
- Set a strong root password and a strong user password. Use the
passwd
command. - Restart sudo with
sudo -k
.
https://pimylifeup.com/raspberry-pi-swap-file/
https://stackoverflow.com/a/77278502/10967630
https://unix.stackexchange.com/questions/537645/how-to-limit-docker-total-resources
- Sign up for a tailscale account at https://login.tailscale.com/start
- Follow onscreen prompts to download and install tailscale on the server
- Sign up for duckdns at https://www.duckdns.org
- Create a subdomain
- Go to "install" tab at top and click on "pi". Follow the instructions to create the
duck.sh
file. - Now edit the file as below
IP=`tailscale ip | head -n 1` echo url="https://www.duckdns.org/update?domains=YOUR_DOMAIN&token=YOUR_TOKENb&ip=$IP" | curl -k -o ~/duckdns/duck.log -K -
- Run the script. Now you should be able to reach the server using the YOUR_DOMAIN.duckdns.org (as long as the other device is also on the same tailscale network.)
https://www.cyberciti.biz/faq/howto-linux-bsd-unix-set-dns-nameserver
Resources:
https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file
nextcloud/previewgenerator#233
Good youtube videos:
https://www.youtube.com/watch?v=fKuqYQdqRIs
Dynamic DNS (DDNS) for Free: Remote Access to Home Server