This repository builds a Docker image based on rocker/r2u that enables:
- SSH access using a base64-encoded public key via
AUTHORIZED_KEYS_B64 sudoinstalled and configured (NOPASSWD) for the main userbspmenabled in R with the sudo backend- A minimal boot script (
boot-sshd.sh) that prepares~/.sshand startssshd
The primary purpose of this image is to enable an R environment with Ubuntu Binaries to run in Positron via SSH.
In terminal (bash/powershell):
git clone https://github.com/jmgirard/r2u-ssh.git
cd r2u-ssh
In terminal (bash/powershell):
ssh-keygen -t ed25519 -C "[email protected]"
Be sure to replace the example email address with your own. Hit enter/return to accept all defaults
Create a .env file at the repo root containing your base64-encoded public key:
macOS/Linux:
{
echo -n "AUTHORIZED_KEYS_B64="
if base64 --help 2>&1 | grep -q '\-w'; then
base64 -w0 ~/.ssh/id_ed25519.pub
else
base64 < ~/.ssh/id_ed25519.pub | tr -d '\n'
fi
echo
echo "USERNAME=rocker"
} > .envWindows (PowerShell):
$pub = Get-Content -Raw "$env:USERPROFILE\.ssh\id_ed25519.pub"
$base64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($pub))
"AUTHORIZED_KEYS_B64=$base64" | Out-File -Encoding ascii .env
"USERNAME=rocker" | Out-File -Append -Encoding ascii .envIn terminal (bash/powershell):
docker compose up -d --build
- Open Positron
- Go to Remote Explorer (left pane)
- Click on the "Configure" (gear) icon to open SSH config
- Paste the following in:
Host r2u-ssh
HostName 127.0.0.1
Port 2222
User rocker
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
- Click the Refresh (cycle) icon
- Click Connect to Host in New Window (window plus) icon next to r2u-ssh
You'll now be connected to a full R environment running inside Docker.
To close the container but keep the image, use:
docker compose down
To close the container and remove the image, use:
docker compose down --rmi all