Learning objectives
- Admin stuff that I won’t dig into:
- Create users in Linux.
- Check and set Linux file permissions.
- Install programs on Debian-based Linux distributions.
- Check storage usage.
- Manage processes.
- Implement SSH port forwarding.
- Locate files on the
$PATH
.
- Set up a data science AWS EC2.
- Run RStudio on an AWS EC2.
- Run JupyterHub on an AWS EC2.
- Run a plumber API in a docker container on an AWS EC2.
Stand up an EC2 (chapter 10 lab review)
- Sign in at console.aws.amazon.com
- Go to EC2 (via services or other routes)
- “Launch instances”
- Fill in the form:
- Name (
do4ds-lab
)
- AMI:
ubuntu
- Type:
t2.micro
is free, might need larger later.
- Key pair: Choose or create.
pem
version no matter what you’re on.
- Security group: Choose or create.
- Storage: For now we aren’t using anything more than the root.
- We’ll add more when we need it in a later lab.
- It’s fine if you already added some, though.
- “Launch instance”
- “Instance state” menu to stop or terminate between labs.
Create a non-root user
- (“Instance state” > “Start instance” to resume)
- Copy “Public IPv4 DNS” (will be
$SERVER_ADDRESS
below)
- something like “ec2-3-123-456-789.compute-1.amazonaws.com”
ssh -i ~/path/to/do4ds-lab-key.pem ubuntu@$SERVER_ADDRESS
sudo adduser test-user
- Give them a password
- Defaults ok for everything else
sudo usermod -aG sudo test-user
(a
dd to G
roup)
Add an ssh key
- Create new key from your local machine (if you don’t have one):
- On Windows:
ssh-keygen
works but it’s fussy
- I named it
id_rsa_test_user
(but then I reverted to my personal id_rsa
!)
- I didn’t use a password
scp
the key to the server
scp -i ~/path/to/do4ds-lab-key.pem ~/path/to/id_rsa.pub ubuntu@@$SERVER_ADDRESS:/home/ubuntu
- On server:
mv
& chown
to user
su test-user
& cd ~
mkdir -p .ssh
, chmod 700 .ssh
, cat id_rsa.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
rm id_rsa.pub
Notes on personal ssh key
I still need -i ~/path/to/id_rsa_test_user
in ssh
call
Is this because I haven’t “set up an SSH config for this server”?
- Update: Nope! It was because I had 2 keys in my local
.ssh
folder
Install R
curl -Ls https://github.com/r-lib/rig/releases/download/latest/rig-linux-arm64-latest.tar.gz | sudo tar xz -C /usr/local
rig add release
R
Install RStudio Server
- Check current installation instructions
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/server/jammy/amd64/rstudio-server-2022.12.0-353-amd64.deb
sudo gdebi rstudio-server-2022.12.0-353-amd64.deb
sudo systemctl status rstudio-server
rm rstudio-server-2022.12.0-353-amd64.deb
Tunnel to see it locally
- On your local machine:
ssh -NL 8787:localhost:8787 test-user@$SERVER_ADDRESS
- I had to add the
N
, I’m not sure what it does (got it from Google)
- It’s alive!
Install Python and JupyterLab
- I did not do this and hope to never do this.
Plumber in docker
sudo apt-get install docker.io
sudo docker ps
to make sure it worked
sudo docker run --rm -d \
-p 8555:8000 \
--name palmer-plumber \
alexkgold/plumber
ssh -NL 8555:localhost:8555 test-user@$SERVER_ADDRESS
- It’s an api!