Passwordless login to remote RPI from VSCODE with public / private keys

Steps to Set Up SSH Key Authentication Between Windows and Raspberry Pi (So You Don’t Have to Enter the Password)

  1. Generate SSH Keys on Windows (If Not Done Already)

You should have generated the SSH key pair on your Windows machine (the one you’re using for VSCode).

Open PowerShell (or Command Prompt) on your Windows machine.
Run the following command to generate an SSH key pair:

ssh-keygen -t rsa -b 4096

Follow the prompts:
    Press Enter to accept the default location for the key (C:\Users\<YourUserName>\.ssh\id_rsa).
    Optionally, enter a passphrase, or leave it blank for no passphrase (easier but less secure).

Now you should have two files in your C:\Users\.ssh directory:

id_rsa (your private key)
id_rsa.pub (your public key)
  1. Copy the Public Key to the Raspberry Pi

You need to copy the public key (id_rsa.pub) to the Raspberry Pi so that it can authenticate you.
Option 1: Using ssh-copy-id (from Windows with Git Bash)

If you have Git Bash installed on your Windows machine, you can use the ssh-copy-id tool to copy the public key to the Raspberry Pi:
    Open Git Bash on Windows.
    Run the following command:

    ssh-copy-id pi@<RPI_IP_ADDRESS>

    Replace <RPI_IP_ADDRESS> with the actual IP address of your Raspberry Pi.
        It will prompt you for the Raspberry Pi password. After entering it, your key will be copied.

Option 2: Manually Copy the Key

If ssh-copy-id is not available, follow these manual steps:

Copy the public key:
    Open id_rsa.pub (located in C:\Users\<YourUserName>\.ssh\id_rsa.pub) with a text editor, and copy its entire content.

Log into the Raspberry Pi:
    Open PowerShell or Command Prompt on Windows, and run:

ssh pi@<RPI_IP_ADDRESS>

Enter the Raspberry Pi password when prompted.

Paste the public key into the authorized_keys file:

On the Raspberry Pi, run:

mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys

Paste the contents of id_rsa.pub into the authorized_keys file.
Save and exit (Ctrl + X, then press Y to confirm, and Enter).

Set the correct permissions:

Run the following commands on the Raspberry Pi to ensure the permissions are correct:

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
  1. Configure SSH to Use Key Authentication (on the Raspberry Pi)

Now, ensure that the SSH server on the Raspberry Pi is configured to allow key-based authentication and disable password authentication (if you want to fully rely on SSH keys).

Edit the SSH configuration file on the Raspberry Pi:

sudo nano /etc/ssh/sshd_config

Ensure the following lines are present and not commented out (# means commented out):

PubkeyAuthentication yes
PasswordAuthentication no (This line will disable password authentication, forcing key-based login)
AuthorizedKeysFile .ssh/authorized_keys

Restart the SSH service to apply changes:

sudo systemctl restart ssh
  1. Test the SSH Connection

Test that SSH key authentication is working by attempting to log in again from your Windows machine:

Open PowerShell or Command Prompt on your Windows machine.

Run the following command:

ssh pi@<RPI_IP_ADDRESS>

You should now be able to log in without a password prompt. If everything is set up correctly, SSH should use the key authentication, and you'll be logged in automatically.
  1. Set Up VSCode to Use SSH

Now that SSH key authentication is working, you can connect from VSCode:

Install the Remote - SSH extension in VSCode if you haven't already.
Configure the SSH connection in VSCode:
    Open Command Palette (Ctrl + Shift + P) in VSCode.
    Type Remote-SSH: Open SSH Configuration File.
    Add an entry for your Raspberry Pi:

    Host raspberrypi
        HostName <RPI_IP_ADDRESS>
        User pi
        IdentityFile C:\Users\<YourUserName>\.ssh\id_rsa

Connect to the Raspberry Pi:
    Open Command Palette (Ctrl + Shift + P) in VSCode again.
    Select Remote-SSH: Connect to Host... and choose your Raspberry Pi entry.

Now, VSCode should connect to your Raspberry Pi without asking for a password each time you reboot your Raspberry Pi.

  1. Troubleshooting If you’re still being asked for a password, check that:
    The private key (id_rsa) is being correctly used.
    The Raspberry Pi’s SSH server is configured to allow key-based authentication (PubkeyAuthentication yes).
    The authorized_keys file on the Raspberry Pi has the correct permissions (chmod 600 ~/.ssh/authorized_keys).

With this setup, you should no longer be prompted for a password after rebooting the Raspberry Pi!

RF attenuator design calculator from standard resistors

PA1B has made a nice calculator to design RF attenuators from standard resistors. You can select if you want to use 0,25W, 1W, 3W, 5W resistors, how much power in W the attenuator shall handle and the attenuation in dB. https://pa1b-qrp.blogspot.com/p/power-attenuator-calculator.html

Here you can download the Excel file (it is safe to use):

Importveid kursindeks. Grafen som viser om norsk krone faktisk er sterk eller svak

Norges bank beregner et geometrisk snitt (ikke aritmetrisk) av 44 valutaer som er de viktigste Norge handler med. Dette kalles importveid kursindeks (I44). Denne gir en god indikasjon på om den norske krona er sterk eller svak uten at en enkelt valuta dominerer bildet. Du kan følge med her: https://www.norges-bank.no/tema/Statistikk/Valutakurser/?tab=currency&id=I44 (Høye verdier betyr svak norsk krone). Vi ser at det helt siden 2012 har vært evekkelse, som så flatet ut på 20 tallet, for så å peake i ca 2020. Men kronen er fortsatt veldig svak. Mange mener dette skyldes bortfall av oljeøkonomien. En svak krone fører til at varene vi importerer fra utlandet blir dyrere. Dermed “importerer” vi inflasjon. Dette påvirker igjen renten. Det er mange som mener at så lenge krona er svak og vi kjøper dyrt fra utlandet så vil ikke renta kunne komme ned igjen siden Norges Bank styrer etter et inflasjonsmål og ikke lenger har pegget valutaen mot sentrale valutaer i europa.

How to use VSCODE remote debuging on a raspberry pi 3 without OS crashes

You will often encounter OS crashes when using VSCODE on a rpi3 for debugging. The cause: memory overflow and too low swap size. If you set the swap memory to 1024MB you will have solved the problem.

Follow these steps (source https://nebl.io/neblio-university/enabling-increasing-raspberry-pi-swap/) ->

1. Temporarily Stop Swap:

sudo dphys-swapfile swapoff

2. Modify the size of the swap

As root, edit the file /etc/dphys-swapfile and modify the variable CONF_SWAPSIZE to 1024:

CONF_SWAPSIZE=1024

Using a command such as:

sudo nano /etc/dphys-swapfile

3. Initialize Swap File

sudo dphys-swapfile setup

4. Start Swap

sudo dphys-swapfile swapo

Motorola AN-749

Motorola’s AN-749 is a classic app. note that describes the principles of broadband transformers for RF amplifiers. It also covers broadband combiners for RF amplifiers. This is a very relevant app note for amateur radio enthusiasts that want to build their own solid state amplifiers.

Simple 5V to 3.3V level shifter

If you need to interface a 3.3V logic unit to a 5V logic CPU board you may be tempted to use the traditional two resistor voltage divider. This will work, however there is an alternative solution that uses one 1N4148 (or similar) diode. When the 5V output (right side) is high, the diode blocks but the 3.3V input is still pulled up by an internal pull up. When the 5V output (right side) is low, the diode conducts and pulls down the input on the left side: 3V input –>|– 5v “output”
The illustration is snipped from stackexchange.com

Hvordan kompilere eldre .NET / C# prosjekter fra Visual Studio i VSCODE (notes to self)

Må ha support for C# utvikling installert i VSCODE. Hvis det er et eldre prosjekt som man henter opp som er laget i Visual Studio så må man ha C# Dev kit installert siden det støtter MSBUILD projects osv. 
https://code.visualstudio.com/docs/languages/csharp

###

Må sjekke at ikke det er feil versjon av dotnet som kjøres med kommando dotnet --info
Installering i et CMD vindu kan skje med winget: https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net70

###

X86 path kan være fær X64 path. Rekkefølgen på path prioriteres
Sjekk PATH ! IKke bare PATH for ALLE brukere, men sjekk path for DIN bruker 
https://github.com/dotnet/core/issues/5962#issuecomment-780084535 MRK denne tutorialen fokuserer på SYSTEM PATH men det var YOUR ACCOUNT PATH som var feil 
Hvis path peker til x86 versjonen av dotnet mens du har installert dev packs osv for X64 versjonen av dotnet så får du feilmeldinger i VSCODE
Må ha core dev installert
List hva som er installert med "dotnet --list-sdks" 

###

Må modde .csproj fila i det opprinnelige prosjektet for å få kopmpilert med VSCODE
https://github.com/dotnet/msbuild/issues/5787

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net48</TargetFramework>
    <GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Resources.Extensions" Version="5.0.0" />
  </ItemGroup>

</Project>


###

Måtte konvertere .csprj fila til nytt format som VSCODE ville godta (fikk build feilmelding) 
Brukte dette toolet på kommandolinje: https://treit.github.io/c%23,/programming/2019/02/18/ConvertingCsProjectsToNewSdkFormat.html

dotnet tool install --global Project2015To2017.Migrate2017.Tool
conv HelloWorld.csproj

Litt mer info om konvertering til nytt CSPROJ format: https://www.hanselman.com/blog/upgrading-an-existing-net-project-files-to-the-lean-new-csproj-format-from-net-core