Shiny on AWS - Install R and R Shiny

This article belongs to the series How to deploy a Shiny app on AWS, divided into 7 parts. To access the other articles, use the following table of contents:

Last time, we stopped right after the creation of your first server on AWS.

In this new article, we’ll learn:

  • how to access the server with SSH
  • how to install R and R Shiny Server on it

How to access your new server?

Once your instance is created, AWS will display a Connect button. If you click on it, you get something like that:

Bouton Connect

These are the instructions to connect to your server.

But it’s not that easy, so let’s take it slowly. Plus, it’s different depending on your OS.

For Windows users

If you’re on Windows, you need to download an SSH client, since the OS doesn’t have one natively.

The most common one is PuTTY, which you can download on

Next, you have to transform the key you downloaded in the previous article. Remember, the file with the pem extension.


  1. Run PuTTYgen (type “PuTTYgen” in the start menu)
  2. Choose RSA.
  3. Select the pem file that you downloaded (you need to activate the option to see all file types).
  4. Save the private key with the same name of your pem file (except the extension will be different, with ppk).

Then, run PuTTY and configure it with what AWS told you:

PuTTY config

  1. In Host Name (or IP address), copy/paste the value you find at the 4th step of the above screenshot (for me, it’s
  2. Port: 22
  3. Connection type: SSH
  4. Go to Connection/SSH/Auth, and load the ppk key that you saved a few seconds ago.

Finally, click “Open”, type “ubuntu” when you’re asked login as, say “Yes”, and a console will open!

That’s it.

You’re in!

PuTTY console

For Ubuntu and Mac users

If you’re not on Windows, things are way easier.

Open a console, change the directory to be in the one that contains the pem key, and type the instruction given by AWS.

For example, for me it’s:

$ cd Downloads/
$ ssh -i "tutorial.pem" [email protected]

Say “yes”, and you’re in!

If you get an error message such as “WARNING: UNPROTECTED PRIVATE KEY FILE!”, it’s normal. You have to change the rights of the file by typing:

$ chmod 400 tutorial.pem

How to install Shiny Server

Next step is to install Shiny Server.

And of course, before that, we need to install R!

The Ubuntu repos contain an outdated version of R. So instead, we first add the CRAN repo:

$ sudo apt-key adv --keyserver --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
$ sudo add-apt-repository 'deb [arch=amd64,i386] bionic/'

Once it’s done, the CRAN repo is added and you can install R:

$ sudo apt update
$ sudo apt install r-base r-base-dev

Once R is installed, we also need to install the shiny package before installing Shiny Server.

Run R in admin mode and install the package:

$ sudo R
> install.packages("shiny")

You can quit R by typing q() and n.


That’s progress.

Final step: Download the last version of Shiny Server.

Go on and scroll down at the bottom of the page to see the instructions, with the version number.

For me, it’s:

$ sudo apt-get install gdebi-core
$ wget
$ sudo gdebi shiny-server-

The last two lines might be different if a new version is released.

Once you launch everything, say “yes”, and everything will get installed!

That’s it!

You don’t know it yet, but you already have a Shiny app running on your server now.

How do I see it?

That’s what we’ll see in the next part…

Part 4 - Deploy the app on the server

You like my articles?

To get updated when I publish new articles, subscribe here:



Leave a Comment

Required fields are marked *


Comments are validated manually. The page will refresh after validation.