Cloud Foundry provides the official command line client cf cli (link) for Single SHell (SSH) logon to application containers or invoking commands inside of containers.
cf ssh APP_NAME [-i app-instance-index] [-c command] [-L [bind_address:]port:host:hostport] [--skip-host-validation] [--skip-remote-execution] [--request-pseudo-tty] [--force-pseudo-tty] [--disable-pseudo-tty]
However, in case of network issues, configuration mistakes or other temporary issues, "cf ssh" fails and it only returns a limited error message as shown below:
FAILED Error opening SSH connection: dial tcp <load balancer IP>:2222: connectex: No connection could be made because the target machine actively refused it.
This article discusses how to enable SSH verbose mode when accessing application containers for troubleshooting purpose.
Follow the steps to resolve this issue:
ssh -vv -p 2222 cf:<APP_GUID>/0@ssh.<system domain>
CF CLI does not provide the "scp" option, which can also be implemented in a similar way by executing "scp" directly. This is an example to copy files from container to localhost.
scp -P 2222 -o User=cf:<APP_GUID>/0 ssh.<system domain>:/<path>/<file name> ./