David Fourie
  • Services
    • Installation or Migration
    • Theme Development
    • Search Engine Optimization
    • Security
    • Speed Optimization
    • Google Search Console
    • Google Tag Manager
    • Google Analytics
    • Marketing Integrations
    • Something Else
  • Portfolio
    • WordPress Installation
    • WordPress Migration
    • Theme Customization
    • Search Engine Optimization
    • Security Optimization
    • Speed Optimization
    • Google Search Console
    • Google Tag Manager
    • Google Analytics
    • Marketing Integrations
  • Articles
    • WordPress
    • Plugin Reviews
    • Freelancing
  • About David
  • Search
  • Menu Menu

AWS Lightsail: Ubuntu 16.04 LTS Upgrade to Ubuntu 18.04 LTS

Looking for the Amazon Lightsail Ubuntu 18.04 LTS Upgrade Guide?

While writing my article on installing OLS on Amazon Lightsail, I experimented with upgrading Ubuntu 16.04 LTS to Ubuntu 18.04 LTS using the guide at nixCraft. Great guide, but it fails to mention that upgrading Ubuntu 16.04 LTS to Ubuntu 18.04 LTS on Amazon Lightsail breaks the Lightsail Browser SSH client. The error message simply says:

An error occurred and we were unable to connect or stay connected to your instance. If this instance has just started up, try again in a minute or two. UPSTREAM_NOT_FOUND [519]

As a result, here is my guide, which fixes the error before it happens. All the commands in this article can be run by connecting to the instance from the Amazon Lightsail dashboard with the Lightsail Browser SSH client.

Error 519

Amazon Lightsail Error 519

Check Swap Space

In my tests, I used the smallest Amazon Lightsail instance, with 512MB RAM. The installation was Ubuntu 16.04 LTS OS-only, so it didn’t have any default swap space. The first upgrade I performed, without swap space, was killed by the system due to running out of memory.

Check that you have swap space!

cat /proc/swaps

Amazon Lightsail with no swap

Amazon Lightsail with no swap

Amazon Lightsail with swap

Amazon Lightsail with swap

If your instance does not have swap space allocated, you can run the following command to allocate 2GB of swap space. Swap space should be twice the size of the instance’s RAM, unless the instance has more than 2GB of RAM. It is not necessary to reboot after allocating swap space – it will start to be used immediately after being made active.

TL;DR

sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile && sudo sed -i '$ a\/swapfile swap swap defaults 0 0' /etc/fstab

Long Version (explanation of the above command string – do not run as separate commands)
Run the command as the root user.

sudo

Allocate space to a file.

fallocate

Specify the length of the file.

-l

Specify the length as 2GB.

2G

Create the file in / with the name “swapfile”.

/swapfile

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Change mode for a file.

chmod

Change the mode to 6(Owner can Read&Write,Not Execute) 0 (Group cannot Read, Write or Execute) 0 (Public cannot Read, Write or Execute).

600

The file that we want to change the mode for is “/swapfile”.

/swapfile

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Prepare a block to be used as swap.

mkswap

The block we want to prepare is “/swapfile”.

/swapfile

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Enable a device of file to be used as swap space.

swapon

The file to use as swap space is “/swapfile”.

/swapfile

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Run SEd

sed

Make changes in-place (in the file we’re editing)

-i

The expression for changes we want to make (add the string to the end of the file)

(Write “/swapfile swap swap defaults 0 0” to /etc/fstab. Fstab is the file system table. The line adds a filesystem of /swapfile with mount point “swap” as type “swap” with options “default”, dump disabled (0) and pass disabled (0). This filesystem will be mounted at reboot because it has been added to fstab.)

'$ a\/swapfile swap swap defaults 0 0'

The file we are editing is

/etc/fstab

Upgrade Ubuntu 16.04 LTS’s Packages

Ubuntu 16.04 LTS will not upgrade to Ubuntu 18.04 LTS without having its own packages updated first.

TL;DR

sudo apt update && sudo DEBIAN_FRONTEND=noninteractive apt -o Dpkg::Options::="--force-confold,confdef" -y full-upgrade && sudo reboot

Long Version (explanation of the above command string – do not run as separate commands)
Run the command as the root user.

sudo

Run the Advanced Package Tool.

apt

Update the list of available packages from sources.

update

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Tell the package manager to run in non-interactive mode.

DEBIAN_FRONTEND=noninteractive

Run the Advanced Package Tool.

apt

Use the following options.

-o

Set the dpkg options to force using of the old configuration file if it exists, else use the default configuration for the package.

Dpkg::Options::="--force-confold,confdef"

Assume yes to all prompts.

-y

Do a full system package upgrade – if removal of installed packages is required, remove them.

full-upgrade

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Reboot the system

reboot

Upgrade Ubuntu 16.04 LTS to Ubuntu 18.04 LTS

We are now ready to upgrade Ubuntu 16.04 LTS to Ubuntu 18.04 LTS and fix the issue with the Amazon Lightsail Browser SSH client at the same time.

(Want to upgrade from Ubuntu 16.04 LTS to Ubuntu 20.04 LTS? Upgrade to Ubuntu 18.04 LTS first, then follow the Ubuntu 18.04 LTS to Ubuntu 20.04 LTS upgrade guide. A direct upgrade is not possible.)

TL;DR

sudo do-release-upgrade -d -f DistUpgradeViewNonInteractive && sudo sed -i -e '/UsePrivilegeSeparation/d' -e '/KeyRegenerationInterval/d' -e '/ServerKeyBits/d' -e '/RSAAuthentication/d' -e '/RhostsRSAAuthentication/d' /etc/ssh/sshd_config && sudo reboot

Long Version (explanation of the above command string – do not run as separate commands)
Run the command as the root user.

sudo

Run the upgrade manager.

do-release-upgrade

Upgrade to the next development release.

-d

Upgrade with the following frontend.

-f

Tell the upgrade manager to run with the non-interactive frontend (old configurations are kept if they exist – if they do not, the default configuration is used).

DistUpgradeViewNonInteractive

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Run SEd

sed

Perform the operations in-place (in the file we are reading from)

-i

Use the expression

-e

Find the expression “UsePrivilegeSeparation” and delete the line in which it appears (d)

'/UsePrivilegeSeparation/d'

Use the expression

-e

Find the expression “KeyRegenerationInterval” and delete the line in which it appears (d)

'/KeyRegenerationInterval/d'

Use the expression

-e

Find the expression “ServerKeyBits” and delete the line in which it appears (d)

'/ServerKeyBits/d'

Use the expression

-e

Find the expression “RSAAuthentication” and delete the line in which it appears (d)

'/RSAAuthentication/d'

Use the expression

-e

Find the expression “RhostsRSAAuthentication” and delete the line in which it appears (d)

'/RhostsRSAAuthentication/d'

Use this file for these operations

/etc/ssh/sshd_config

If the previous command executed successfully, do the next, else stop.

&&

Run the command as the root user.

sudo

Reboot the system

reboot

Amazon Lightsail Browser SSH Client Error 519 After Upgrade

Using this method, we will have avoided the “Upstream Not Found [519]” error message in the Amazon Lightsail Browser SSH client.

Why Does The Upstream Not Found [519] Error Happen?

Ubuntu 16.04 LTS uses OpenSSH Version 7.2, whereas Ubuntu 18.04 LTS uses OpenSSH Version 7.6. In OpenSSH Version 7.6, deprecated settings from Version 7.2 causes problems in the Amazon Lightsail Browser SSH client connection. By removing these deprecated settings from the SSH Configuration File (/etc/ssh/sshd_config), we restore the ability of the Amazon Lightsail Browser SSH client to connect to the instance.

I Didn’t Follow This Guide. How Do I Fix The Upstream Not Found [519] Error?

Connect to your Lightsail instance using PuTTY and run the following in the terminal:

sudo sed -i -e '/UsePrivilegeSeparation/d' -e '/KeyRegenerationInterval/d' -e '/ServerKeyBits/d' -e '/RSAAuthentication/d' -e '/RhostsRSAAuthentication/d' /etc/ssh/sshd_config && sudo systemctl restart ssh

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Skype (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to email this to a friend (Opens in new window)
  • Click to print (Opens in new window)

Hire Me!

Upwork.com

Sparrows Children’s Home

Sparrows Children's Home

It costs R50 (~$3)
per day to provide a child with food.
Please consider a small donation.

A2 Hosting
LiteSpeed Web Server
Jetpack
© 2011 - 2021 FMC. All Rights Reserved.
  • Twitter
  • Facebook
  • LinkedIn
  • Privacy Policy
WordPress Page Speed and Site Speed Page speed: what is it, what is measured and how can it be improved? Ubuntu 18.04 LTS Upgrade to Ubuntu 20.04 LTS AWS Lightsail: Ubuntu 18.04 Scroll to top

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.

Accept settingsHide notification onlySettings

Cookie and Privacy Settings



How we use cookies

We may request cookies to be set on your device. We use cookies to let us know when you visit our websites, how you interact with us, to enrich your user experience, and to customize your relationship with our website.

Click on the different category headings to find out more. You can also change some of your preferences. Note that blocking some types of cookies may impact your experience on our websites and the services we are able to offer.

Essential Website Cookies

These cookies are strictly necessary to provide you with services available through our website and to use some of its features.

Because these cookies are strictly necessary to deliver the website, refuseing them will have impact how our site functions. You always can block or delete cookies by changing your browser settings and force blocking all cookies on this website. But this will always prompt you to accept/refuse cookies when revisiting our site.

We fully respect if you want to refuse cookies but to avoid asking you again and again kindly allow us to store a cookie for that. You are free to opt out any time or opt in for other cookies to get a better experience. If you refuse cookies we will remove all set cookies in our domain.

We provide you with a list of stored cookies on your computer in our domain so you can check what we stored. Due to security reasons we are not able to show or modify cookies from other domains. You can check these in your browser security settings.

Other external services

We also use different external services like Google Webfonts, Google Maps, and external Video providers. Since these providers may collect personal data like your IP address we allow you to block them here. Please be aware that this might heavily reduce the functionality and appearance of our site. Changes will take effect once you reload the page.

Google Webfont Settings:

Google Map Settings:

Google reCaptcha Settings:

Vimeo and Youtube video embeds:

Privacy Policy

You can read about our cookies and privacy settings in detail on our Privacy Policy Page.

Privacy Policy
Accept settingsHide notification only

Add David Fourie to your Homescreen!

Add
loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.