Using SSH to Access Your App in Cloud Foundry

Hands-On Lab

 

Photo of Travis Thomsen

Travis Thomsen

Course Development Director in Content

Length

01:30:00

Difficulty

Intermediate

In this hands-on lab, you are a DevOps Engineer. Your application has an API Key in key.txt located in the /app directory. You need to retrieve the key and save it in the application directory. This lab will show you how to access an app instance in Cloud Foundry.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Using SSH to Access Your App in Cloud Foundry

Introduction

In this hands-on lab, you are a DevOps Engineer. Your application has an API Key in key.txt located in the /app directory. You need to retrieve the key and save it in the application directory. This lab will show you how to access an app instance in Cloud Foundry.

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page:

    ssh cloud_user@PUBLIC_IP_ADDRESS
  2. Become the root user:

    sudo su -

Register for a Pivotal Cloud Foundry account

  1. Register for a Pivotal Cloud Foundry account (if you do not have one already):

Log in to Pivotal Cloud Foundry

  1. Use the cf-cli to log in to your Pivotal Cloud Foundry account.

    cf login -a api.run.pivotal.io
    • Email: Enter the email address for your Pivotal Cloud Foundry account.
    • Password: Enter the password for your Pivotal Cloud Foundry account.
  2. Clean up any lingering resources.

    cf apps

    If any apps are listed that need to be removed, delete them:

    cf delete <APP NAME>

Recover the Data from key.txt

  1. Change directories to the ssh-key directory:

    cd ssh-key/
  2. Execute a cf push to bootstrap the environment.

    cf push
  3. After the app is deployed, you need to access it to recover the data that is in key.txt. The file is located in /app.

    cf ssh key-node -c "cat /app/key.txt" > key.txt

Clean up the Environment

  1. Delete the key-node application:

    cf delete key-node
  2. Verify it is no longer listed:

    cf apps 

Conclusion

Congratulations — you've completed this hands-on lab!