• Skip to main content

Uly.me

cloud engineer

  • Home
  • Archives
  • Search

os

GCP Compute Enable OS Login

May 27, 2021 by Ulysses

If you have trouble logging in (SSH) to your GCP instance, you may have to enable OS Login.

gcloud compute instances add-metadata server-name \
--metadata enable-oslogin=TRUE \
--zone us-central1-c \
--project project-id

gcloud compute instances add-metadata server-name \ --metadata enable-oslogin=TRUE \ --zone us-central1-c \ --project project-id

When done, you can set it back to FALSE.

Filed Under: Cloud Tagged With: compute, gcloud, gcp, login, os, true

AWS LightSail Blueprints

January 1, 2021 by Ulysses

Amazon Lightsail offers a variety of OS blueprints, starting from Amazon Linux 2, Ubuntu 20, Windows Server 2019 to Debian 10 to name just a few. Blueprints are a curated selection of operating systems and software that are preinstalled for the creation of instances. For brevity, only a subset of blueprints are displayed below. The description and licenseUrl portions are truncated. To display an entire list of LightSail blueprints, run this command.

aws lightsail get-blueprints --region us-east-1

aws lightsail get-blueprints --region us-east-1

Output:

{
  "blueprints": [
        {
            "blueprintId": "ubuntu_20_04",
            "name": "Ubuntu",
            "group": "ubuntu_20",
            "type": "os",
            "description": "Ubuntu 20.04 LTS - Focal. Lean, fast and powerful, Ubuntu Server delivers services reliably ...",
            "isActive": true,
            "minPower": 0,
            "version": "20.04 LTS",
            "versionCode": "1",
            "productUrl": "https://aws.amazon.com/marketplace/pp/B087QQNGF1",
            "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/aced0818- ... .txt",
            "platform": "LINUX_UNIX"
        },
        {
            "blueprintId": "wordpress",
            "name": "WordPress",
            "group": "wordpress",
            "type": "app",
            "description": "Bitnami, the leaders in application packaging, and Automattic, the experts behind WordPress .... ",
            "isActive": true,
            "minPower": 0,
            "version": "5.6.0",
            "versionCode": "1",
            "productUrl": "https://aws.amazon.com/marketplace/pp/B00NN8Y43U",
            "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/7d426cb7- ... .txt",
            "platform": "LINUX_UNIX"
        }
}

{ "blueprints": [ { "blueprintId": "ubuntu_20_04", "name": "Ubuntu", "group": "ubuntu_20", "type": "os", "description": "Ubuntu 20.04 LTS - Focal. Lean, fast and powerful, Ubuntu Server delivers services reliably ...", "isActive": true, "minPower": 0, "version": "20.04 LTS", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B087QQNGF1", "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/aced0818- ... .txt", "platform": "LINUX_UNIX" }, { "blueprintId": "wordpress", "name": "WordPress", "group": "wordpress", "type": "app", "description": "Bitnami, the leaders in application packaging, and Automattic, the experts behind WordPress .... ", "isActive": true, "minPower": 0, "version": "5.6.0", "versionCode": "1", "productUrl": "https://aws.amazon.com/marketplace/pp/B00NN8Y43U", "licenseUrl": "https://d7umqicpi7263.cloudfront.net/eula/product/7d426cb7- ... .txt", "platform": "LINUX_UNIX" } }

In this example, I’m using the query option to display only the blueprints ids.

aws lightsail get-blueprints --query 'blueprints[*].[blueprintId]' --output text --region us-east-1

aws lightsail get-blueprints --query 'blueprints[*].[blueprintId]' --output text --region us-east-1

Output:

windows_server_2019
windows_server_2016
windows_server_2012
windows_server_2016_sql_2016_express
amazon_linux_2
amazon_linux
ubuntu_20_04
ubuntu_18_04
ubuntu_16_04_2
debian_10
debian_9_5
debian_8_7
freebsd_12
opensuse_15_1
centos_7_1901_01
wordpress
wordpress_multisite
lamp_7
nodejs
joomla
magento
mean
drupal
gitlab
redmine
nginx
ghost_bitnami
django_bitnami
plesk_ubuntu_18_0_28
cpanel_whm_linux

windows_server_2019 windows_server_2016 windows_server_2012 windows_server_2016_sql_2016_express amazon_linux_2 amazon_linux ubuntu_20_04 ubuntu_18_04 ubuntu_16_04_2 debian_10 debian_9_5 debian_8_7 freebsd_12 opensuse_15_1 centos_7_1901_01 wordpress wordpress_multisite lamp_7 nodejs joomla magento mean drupal gitlab redmine nginx ghost_bitnami django_bitnami plesk_ubuntu_18_0_28 cpanel_whm_linux

Filed Under: Cloud Tagged With: application, aws, blueprints, lightsail, os

LightSail Upstream Error 515

July 6, 2020 by Ulysses

If you use LightSail, AWS provides an easy way for you to connect to LightSail instances via Web SSH. I normally use a terminal (ssh client) to connect to LightSail instances, but using Web SSH is very convenient. If you try to do an OS upgrade, for example from Ubuntu 18.04 LTS to Ubuntu 20.04 LTS, you will break Web SSH. AWS has added a special Web SSH configuration on LightSail base images. The error you’ll get is “Upstream Error 515.” The only way to fix this is to get AWS Support to help you apply the fix. It’s not a make or break it deal, but it can be a nuisance if you prefer to use AWS Web SSH instead of a terminal. If you need a more secure SSH connection, consider uploading your ssh-key to the server, and disable password login.

Filed Under: Cloud, Linux Tagged With: aws, error 515, lightsail, os, upgrade, web ssh

Detect Device, OS, Browser

March 12, 2014 by Ulysses

If you like to deliver specific content to a certain device type, you can use PHP’s server environment settings to know what type of device, operating systems, and browser type is being used. The server environment setting we are interested in is ‘HTTP_USER_AGENT.’ This index contains a string that is given off by the user agent, the browser in this case. All devices pass down pieces of information identifying themselves, including the type of device, operating system, and browser that is being used.

If we were to look for an iPad for example, we need to perform the following commands:

$iPad   = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
if ($iPad) { 
  echo 'This is an iPad'; 
} else { 
  echo 'This is not'; 
}

$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad"); if ($iPad) { echo 'This is an iPad'; } else { echo 'This is not'; }

Other Devices

$user_agent = $_SERVER['HTTP_USER_AGENT'];
 
$iPad   = stripos($user_agent,"iPad");
$iPod   = stripos($user_agent,"iPod");
$iPhone = stripos($user_agent,"iPhone");
$webOS  = stripos($user_agent,"webOS");
$BlackBerry = stripos($user_agent,"BlackBerry");
$RimTablet= stripos($user_agent,"RIM Tablet");
 
if (stripos($user_agent,"Android") && stripos($user_agent,"mobile")) { 
  $Android = true;
} elseif(stripos($user_agent,"Android")){
  $AndroidTablet = true;
}
 
if ($AndroidTablet) {
  echo 'This is an Android Tablet';
} else {
  echo 'This is not an Android Tablet';
}

$user_agent = $_SERVER['HTTP_USER_AGENT']; $iPad = stripos($user_agent,"iPad"); $iPod = stripos($user_agent,"iPod"); $iPhone = stripos($user_agent,"iPhone"); $webOS = stripos($user_agent,"webOS"); $BlackBerry = stripos($user_agent,"BlackBerry"); $RimTablet= stripos($user_agent,"RIM Tablet"); if (stripos($user_agent,"Android") && stripos($user_agent,"mobile")) { $Android = true; } elseif(stripos($user_agent,"Android")){ $AndroidTablet = true; } if ($AndroidTablet) { echo 'This is an Android Tablet'; } else { echo 'This is not an Android Tablet'; }

Detect OS Type

$user_agent = $_SERVER['HTTP_USER_AGENT'];
 
if (preg_match('/linux/i', $user_agent)) { $platform = 'linux'; }
if (preg_match('/macintosh|mac os x/i', $user_agent)) { $platform = 'mac'; }
if (preg_match('/windows|win32/i', $user_agent)) { $platform = 'windows'; }
 
if ($platform == 'windows') {
  // do something
}

$user_agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('/linux/i', $user_agent)) { $platform = 'linux'; } if (preg_match('/macintosh|mac os x/i', $user_agent)) { $platform = 'mac'; } if (preg_match('/windows|win32/i', $user_agent)) { $platform = 'windows'; } if ($platform == 'windows') { // do something }

Detect Browser Type

$user_agent = $_SERVER['HTTP_USER_AGENT'];
 
if (preg_match('/MSIE/i',$user_agent)) { $browser = 'Internet Explorer'; }
if (preg_match('/Firefox/i',$user_agent)) { $browser = 'Mozilla Firefox'; }
if (preg_match('/Chrome/i',$user_agent)) { $browser = 'Google Chrome'; }
if (preg_match('/Safari/i',$user_agent)) { $browser = 'Apple Safari'; }
if (preg_match('/Opera/i',$user_agent)) { $browser = 'Opera'; }
if (preg_match('/Netscape/i',$user_agent)) { $browser = 'Netscape'; }
 
if ($browser == 'Google Chrome') {
  // do something
}

$user_agent = $_SERVER['HTTP_USER_AGENT']; if (preg_match('/MSIE/i',$user_agent)) { $browser = 'Internet Explorer'; } if (preg_match('/Firefox/i',$user_agent)) { $browser = 'Mozilla Firefox'; } if (preg_match('/Chrome/i',$user_agent)) { $browser = 'Google Chrome'; } if (preg_match('/Safari/i',$user_agent)) { $browser = 'Apple Safari'; } if (preg_match('/Opera/i',$user_agent)) { $browser = 'Opera'; } if (preg_match('/Netscape/i',$user_agent)) { $browser = 'Netscape'; } if ($browser == 'Google Chrome') { // do something }

With the sample code above, you can pretty much single out any device and deliver specific content to it.

Filed Under: PHP Tagged With: browser, device, os

  • Home
  • About
  • Contact

Copyright © 2022