Set PS1 on login?
Hello, Happy (mostly) tramp user here that is also very new to it. As someone working with remote machines that I do not own or control, TRAMPs inability to handle fancy prompts is highly crippling. It's stated in the FAQ that " tramp needs a clean recognizable prompt on the remote host for accurate parsing". What I don't understand is why tramp can't set PS1 when logging in the typical way one does: ssh ... -t 'PS1='$'; bash -i' When I modify tramp-maybe-open-connection to do this it works just fine; I'm able to login to a remote that would hang with the message: Tramp: Waiting for prompts from remote shell...fail I figure there is a good reason this can't be done, but wanted to raise the issue just in case. Regards, John C. ___ Tramp-devel mailing list Tramp-devel@gnu.org https://lists.gnu.org/mailman/listinfo/tramp-devel
Re: Set PS1 on login?
John Collins writes: > Hello, Hi John, > Happy (mostly) tramp user here that is also very new to it. As someone > working with remote machines that I do not own or control, TRAMPs > inability to handle fancy prompts is highly crippling. It's stated in > the FAQ that "tramp needs a clean recognizable prompt on the remote > host for accurate parsing". What I don't understand is why tramp can't > set PS1 when logging in the typical way one does: > > ssh ... -t 'PS1='$'; bash -i' > > When I modify tramp-maybe-open-connection to do this it works just > fine; I'm able to login to a remote that would hang with the message: > > Tramp: Waiting for prompts from remote shell...fail > > I figure there is a good reason this can't be done, but wanted to > raise the issue just in case. ssh does not allow this kind of environment passing. Try in your local shell --8<---cut here---start->8--- # ssh localhost "PS1='$ '; /bin/sh" --8<---cut here---end--->8--- or --8<---cut here---start->8--- # ssh localhost "/usr/bin/env PS1='$ ' /bin/sh" --8<---cut here---end--->8--- It doesn't work. Therefore, Tramp cannot use this mechanism. Instead, Tramp recommends to adapt the remote prompt by something like this in the remote ~/.profile: --8<---cut here---start->8--- [ $TERM = "dumb" ] PS1='$ ' --8<---cut here---end--->8--- > Regards, > > John C. Best regards, Michael. ___ Tramp-devel mailing list Tramp-devel@gnu.org https://lists.gnu.org/mailman/listinfo/tramp-devel
Re: Set PS1 on login?
You may have an alternate way of setting PS1 at the client, though the server may be configured to ignore it. The ssh man page says this on my system: Additionally, ssh reads ~/.ssh/environment, and adds lines of the format ``VARNAME=vale'' to the environment if the file exists and users are allowed to change their environment. For more information, see the PermitUserEnvironment option in sshd_config(5). -y On Mon, Jun 11, 2018 at 9:29 AM, Michael Albinus wrote: > John Collins writes: > > > Hello, > > Hi John, > > > Happy (mostly) tramp user here that is also very new to it. As someone > > working with remote machines that I do not own or control, TRAMPs > > inability to handle fancy prompts is highly crippling. It's stated in > > the FAQ that "tramp needs a clean recognizable prompt on the remote > > host for accurate parsing". What I don't understand is why tramp can't > > set PS1 when logging in the typical way one does: > > > > ssh ... -t 'PS1='$'; bash -i' > > > > When I modify tramp-maybe-open-connection to do this it works just > > fine; I'm able to login to a remote that would hang with the message: > > > > Tramp: Waiting for prompts from remote shell...fail > > > > I figure there is a good reason this can't be done, but wanted to > > raise the issue just in case. > > ssh does not allow this kind of environment passing. Try in your local > shell > > --8<---cut here---start->8--- > # ssh localhost "PS1='$ '; /bin/sh" > --8<---cut here---end--->8--- > > or > > --8<---cut here---start->8--- > # ssh localhost "/usr/bin/env PS1='$ ' /bin/sh" > --8<---cut here---end--->8--- > > It doesn't work. Therefore, Tramp cannot use this mechanism. > > Instead, Tramp recommends to adapt the remote prompt by something like > this in the remote ~/.profile: > > --8<---cut here---start->8--- > [ $TERM = "dumb" ] PS1='$ ' > --8<---cut here---end--->8--- > > > Regards, > > > > John C. > > Best regards, Michael. > > ___ > Tramp-devel mailing list > Tramp-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/tramp-devel > ___ Tramp-devel mailing list Tramp-devel@gnu.org https://lists.gnu.org/mailman/listinfo/tramp-devel
Re: Set PS1 on login?
Or better see https://superuser.com/questions/163167/when-sshing-how-can-i-set-an-environment-variable-on-the-server-that-changes-f ...you can pass information in the TERM environment variable, which is always copied (there may be a length limit however). You'll still have to make sure that the remote shell doesn't restrict the TERM variable to designate a known terminal type. Pass the -t option to ssh if you're not starting a remote interactive shell. env TERM="extra information:$TERM" ssh -t server.example.com 'MYVAR=${TERM%:*}; TERM=${TERM##*:}; export MYVAR; mycommand' -y On Mon, Jun 11, 2018 at 9:49 AM, yary wrote: > You may have an alternate way of setting PS1 at the client, though the > server may be configured to ignore it. The ssh man page says this on my > system: > > Additionally, ssh reads ~/.ssh/environment, and adds lines of the format > ``VARNAME=vale'' to the environment if the file exists and users are > allowed to change their environment. For more information, see the > PermitUserEnvironment option in sshd_config(5). > > > -y > > On Mon, Jun 11, 2018 at 9:29 AM, Michael Albinus > wrote: > >> John Collins writes: >> >> > Hello, >> >> Hi John, >> >> > Happy (mostly) tramp user here that is also very new to it. As someone >> > working with remote machines that I do not own or control, TRAMPs >> > inability to handle fancy prompts is highly crippling. It's stated in >> > the FAQ that "tramp needs a clean recognizable prompt on the remote >> > host for accurate parsing". What I don't understand is why tramp can't >> > set PS1 when logging in the typical way one does: >> > >> > ssh ... -t 'PS1='$'; bash -i' >> > >> > When I modify tramp-maybe-open-connection to do this it works just >> > fine; I'm able to login to a remote that would hang with the message: >> > >> > Tramp: Waiting for prompts from remote shell...fail >> > >> > I figure there is a good reason this can't be done, but wanted to >> > raise the issue just in case. >> >> ssh does not allow this kind of environment passing. Try in your local >> shell >> >> --8<---cut here---start->8--- >> # ssh localhost "PS1='$ '; /bin/sh" >> --8<---cut here---end--->8--- >> >> or >> >> --8<---cut here---start->8--- >> # ssh localhost "/usr/bin/env PS1='$ ' /bin/sh" >> --8<---cut here---end--->8--- >> >> It doesn't work. Therefore, Tramp cannot use this mechanism. >> >> Instead, Tramp recommends to adapt the remote prompt by something like >> this in the remote ~/.profile: >> >> --8<---cut here---start->8--- >> [ $TERM = "dumb" ] PS1='$ ' >> --8<---cut here---end--->8--- >> >> > Regards, >> > >> > John C. >> >> Best regards, Michael. >> >> ___ >> Tramp-devel mailing list >> Tramp-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/tramp-devel >> > > ___ Tramp-devel mailing list Tramp-devel@gnu.org https://lists.gnu.org/mailman/listinfo/tramp-devel
Re: Set PS1 on login?
Thanks for the fast responses. Apologies, I should have red the man page more carefully. That looks like a good solution. On Mon, Jun 11, 2018, 10:03 AM yary wrote: > Or better see > https://superuser.com/questions/163167/when-sshing-how-can-i-set-an-environment-variable-on-the-server-that-changes-f > > ...you can pass information in the TERM environment variable, which is > always copied (there may be a length limit however). You'll still have to > make sure that the remote shell doesn't restrict the TERM variable to > designate a known terminal type. Pass the -t option to ssh if you're not > starting a remote interactive shell. > > env TERM="extra information:$TERM" ssh -t server.example.com > 'MYVAR=${TERM%:*}; TERM=${TERM##*:}; export MYVAR; mycommand' > > > > > -y > > On Mon, Jun 11, 2018 at 9:49 AM, yary wrote: > >> You may have an alternate way of setting PS1 at the client, though the >> server may be configured to ignore it. The ssh man page says this on my >> system: >> >> Additionally, ssh reads ~/.ssh/environment, and adds lines of the format >> ``VARNAME=vale'' to the environment if the file exists and users are >> allowed to change their environment. For more information, see the >> PermitUserEnvironment option in sshd_config(5). >> >> >> -y >> >> On Mon, Jun 11, 2018 at 9:29 AM, Michael Albinus >> wrote: >> >>> John Collins writes: >>> >>> > Hello, >>> >>> Hi John, >>> >>> > Happy (mostly) tramp user here that is also very new to it. As someone >>> > working with remote machines that I do not own or control, TRAMPs >>> > inability to handle fancy prompts is highly crippling. It's stated in >>> > the FAQ that "tramp needs a clean recognizable prompt on the remote >>> > host for accurate parsing". What I don't understand is why tramp can't >>> > set PS1 when logging in the typical way one does: >>> > >>> > ssh ... -t 'PS1='$'; bash -i' >>> > >>> > When I modify tramp-maybe-open-connection to do this it works just >>> > fine; I'm able to login to a remote that would hang with the message: >>> > >>> > Tramp: Waiting for prompts from remote shell...fail >>> > >>> > I figure there is a good reason this can't be done, but wanted to >>> > raise the issue just in case. >>> >>> ssh does not allow this kind of environment passing. Try in your local >>> shell >>> >>> --8<---cut here---start->8--- >>> # ssh localhost "PS1='$ '; /bin/sh" >>> --8<---cut here---end--->8--- >>> >>> or >>> >>> --8<---cut here---start->8--- >>> # ssh localhost "/usr/bin/env PS1='$ ' /bin/sh" >>> --8<---cut here---end--->8--- >>> >>> It doesn't work. Therefore, Tramp cannot use this mechanism. >>> >>> Instead, Tramp recommends to adapt the remote prompt by something like >>> this in the remote ~/.profile: >>> >>> --8<---cut here---start->8--- >>> [ $TERM = "dumb" ] PS1='$ ' >>> --8<---cut here---end--->8--- >>> >>> > Regards, >>> > >>> > John C. >>> >>> Best regards, Michael. >>> >>> ___ >>> Tramp-devel mailing list >>> Tramp-devel@gnu.org >>> https://lists.gnu.org/mailman/listinfo/tramp-devel >>> >> >> > ___ Tramp-devel mailing list Tramp-devel@gnu.org https://lists.gnu.org/mailman/listinfo/tramp-devel
Re: Set PS1 on login?
yary writes: > ...you can pass information in the TERM environment variable, which is > always copied (there may be a length limit however). You'll still have > to make sure that the remote shell doesn't restrict the TERM variable > to designate a known terminal type. Pass the -t option to ssh if > you're not starting a remote interactive shell. > > env TERM="extra information:$TERM" ssh -t server.example.com > 'MYVAR=${TERM%:*}; TERM=${TERM##*:}; export MYVAR; mycommand' Why shall one do this? Tramp sets the remote TERM environment variable to "dumb", so you could check it. If you dislike this value, set variable `tramp-terminal-type' to whatever you want, at your own risk. --8<---cut here---start->8--- (let ((tramp-terminal-type "whatever") (default-directory "/ssh::")) (shell-command-to-string "echo $TERM")) --8<---cut here---end--->8--- > -y Best regards, Michael. ___ Tramp-devel mailing list Tramp-devel@gnu.org https://lists.gnu.org/mailman/listinfo/tramp-devel