Jenny Hilton
Jenny Hilton

Reputation: 1407

How to use get cf ssh-code password

We are using CF Diego API 2.89 version, Currently I was able to use it and see the vcap and the app resources when running cf ssh myApp. Now it's become harder :-)

I want to deploy App1 that will "talk" with "APP2" and have access to to it file system (as it available in the command line when you run ls...) via code (node.js), is it possible ?

I've found this lib which are providing the ability to connect to ssh via code but not sure what I should put inside host port etc

In the connect I provided the password which should be retrieved via code

EDIT

});
}).connect({
host: 'ssh.cf.mydomain.com',
port: 2222,
username: 'cf:181c32e2-7096-45b6-9ae6-1df4dbd74782/0',
password:'qG0Ztpu1Dh'

});

Now when I use cf ssh-code (To get the password) I get lot of requests which I try to simulate with Via postman without success, Could someone can assist? I Need to get the password value somehow ... if I dont provide it I get following error:

SSH Error: All configured authentication methods failed

Btw, let's say that I cannot use CF Networking functionality, volume services and I know that the container is ephemeral....

Upvotes: 0

Views: 1515

Answers (2)

Daniel Mikusa
Daniel Mikusa

Reputation: 15006

The process of what happens behind the scenes when you run cf ssh is documented here.

  1. It obtains an ssh token, this is the same as running cf ssh-code, which is just getting an auth code from UAA. If you run CF_TRACE=true cf ssh-code you can see exactly what it's doing behind the scenes to get that code.

  2. You would then need an SSH client (probably a programmatic one) to connect using the following details:

    • port -> 2222
    • user -> cf:<app-guid>/<app-instance-number> (ex: cf:54cccad6-9bba-45c6-bb52-83f56d765ff4/0`)
    • host -> ssh.system_domain (look at cf curl /v2/info if you're not sure)

Having said this, don't go this route. It's a bad idea. The file system for each app instance is ephemeral. Even if you're connecting from other app instances to share the local file system, you can still lose the contents of that file system pretty easily (cf restart) and for reasons possibly outside of your control (unexpected app crash, platform admin does a rolling upgrade, etc).

Instead store your files externally, perhaps on S3 or a similar service, or look at using Volume services.

Upvotes: 2

K.AJ
K.AJ

Reputation: 1292

I have exclusively worked with PCF, so please take my advice with a grain of salt given your Bluemix platform.

If you have a need to look at files created by App2 from App1, what you need is a common resource.

You can inject an S3 resource as a CUPS service and create a service instance and bind to both apps. That way both will read / write to the same S3 endpoint.

Quick Google search for Bluemix S3 Resource shows - https://console.bluemix.net/catalog/infrastructure/cloud_object_storage


Ver 1.11 of Pivotal Cloud Foundry comes with Volume Services.

Seems like Bluemix has a similar resource - https://console.bluemix.net/docs/containers/container_volumes_ov.html#container_volumes_ov

You may want to give that a try.

Upvotes: 0

Related Questions