cli icon indicating copy to clipboard operation
cli copied to clipboard

cf ssh should have `--login` switch

Open dgodd opened this issue 9 years ago • 7 comments

Command

cf ssh myapp

What occurred

I was logged in to my container as expected.

I would like a new switch, --login which means that profile scripts are run for me, so that I can immediately perform tasks which require the environment to be set up.

If this were so, I could for instance do

cf ssh --login myapp
bin/rails console

Currently when I try

cf ssh myapp
bin/rails console

I receive an error since the environment is not setup.

dgodd avatar Aug 08 '17 12:08 dgodd

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/150042279

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar Aug 08 '17 12:08 cf-gitbot

Hi @dgodd

I assume the --login is inspired by the bash flag that reads the profile files, and both native ssh and cf ssh do not (and should not) do this be default as profile scripts out there may not be idempotent?

How do you currently work around this?

$ cf ssh myapp
vcap@...:~$ . .p<tab><enter>
vcap@...:~$ bin/rails console

?

Cheers, Dies Koper CF CLI PM

dkoper avatar Aug 09 '17 03:08 dkoper

The challenge is that it is important for users to source the files in the profile.d directory, and in the correct order. Simply sourcing .profile, or ".profile.d/*" doesn't do the trick.

We on the buildpack team have discussed adding a file to call these in order, but feel that baking something into the system improves the user experience.

I am happy to make a PR if you would be interested in receiving it.

dgodd avatar Aug 10 '17 03:08 dgodd

I wonder why we're trying to address the issue in cf ssh and not "bake something into the system" on the server side so it applies to any ssh client? That's a lot of server side shell logic that the client would need to know about and maintain: if the server terminal is bash, and the flag is set, invoke this script, then that one (if it exists), else that one... If it's a docker image with a different terminal, invoke these instead...? Also, I would think this is a common enough inconvenience (i.e. for anyone ssh'ing into any server) that there should be a common solution? (Which seems to be something like using .bashrc on the server side?)

dkoper avatar Aug 10 '17 04:08 dkoper

The problem with a pure server side solution is that it is believed that many people have profile files in their apps which are not idempotent, and thus changing default behavior to run them is risky. Admittedly if we somehow only run the buildpack provided scripts (not app provided) then the risk is better. Are you open to a flag which is passed through to the server somehow to run the desired setup?

On Thu, Aug 10, 2017, 12:37 AM Dies Koper [email protected] wrote:

I wonder why we're trying to address the issue in cf ssh and not "bake something into the system" on the server side so it applies to any ssh client? That's a lot of server side shell logic that the client would need to know about and maintain: if the server terminal is bash, and the flag is set, invoke this script, then that one (if it exists), else that one... If it's a docker image with a different terminal, invoke these instead...? Also, I would think this is a common enough inconvenience (i.e. for anyone ssh'ing into any server) that there should be a common solution? (Which seems to be something like using .bashrc on the server side?)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cloudfoundry/cli/issues/1196#issuecomment-321448829, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHtTc_jSsdPklynAZd_npW9xdkqwJLmks5sWokegaJpZM4OwqgQ .

dgodd avatar Aug 10 '17 09:08 dgodd

How would the (cf ssh) user be able to tell whether their app has any non-idempotent profile files and therefore whether it's safe or risky to specify a --login flag?

Would the buildpack and app developer know what is safe and what is not, and could they be instructed to have the safe ones be executed by ~/.bashrc (which I understand is executed in case of a non-login interactive shell as is the case with any ssh client), so that cf ssh users just get the environment set up without needing to first scan through the profile scripts to see if it's safe to use an unfamiliar new option?

dkoper avatar Aug 10 '17 11:08 dkoper

Closing. Labeled wontfix for over 3 months without new input.

jbpivotal avatar Jan 12 '18 04:01 jbpivotal