How to SSH into an app container using a different port from the default port used in the command 'cf ssh'
search cancel

How to SSH into an app container using a different port from the default port used in the command 'cf ssh'

book

Article ID: 297691

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

Symptoms:
Currently, running the Cloud Foundry Line Interface (cf CLI) command cf ssh forces users to use port 2222.

Environment


Cause

cf ssh doesn't allow you to change the default port. In some cases, there is a load balancer that is listening to a different port and that port cannot be changed for security reasons.

Resolution

The workaround to this issue is to execute ssh directly against the load balancer IP and PORT as explained below: 

1. Retrieve a one-time passcode by executing the following command: cf ssh-code

2. Retrieve the application Global Unique Identifier (GUID) by executing the following command: cf app APP_NAME --guid

Note: Replace APP_NAME with your own app name.

3. SSH into the container and replace the PORT, APP_GUID and the LB-IP (load balancer IP):
ssh -p <PORT> cf:<APP_GUID>/0@<LB-IP>
4. Input the passcode retrieved in step 1 when prompted.