-
-
Notifications
You must be signed in to change notification settings - Fork 542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect to appserver container with SSH (without cli) #2188
Comments
So if you wanted to connect to a lando service via ssh youd be responsible for setting up and managing that entire interaction |
What do you mean by this? How do I do that per se? This is the only thing left for me to switch to lando vs homestead for my app.. |
Hey @ruelluna any updates on tihs? |
Well that's a very confusing decision, to my mind. It's also crazy that this isn't mentioned at https://docs.lando.dev/cli/ssh.html (I think it should be highlighted). Could someone please explain what this does use, and where to find documentation for it? (In my case I currently want to know how to replicate the SendEnv / AcceptEnv ssh config options, but general documentation would be much appreciated.) |
You can see what a lando command is doing in the background by making it very verbose with So it's just using docker exec to launch bash (or fall back to sh). How does that relate to ssh? Given the most prominent user base of Lando is web developers who are most familiar with ssh in the context of getting a bash prompt that is executing on a web server, I assume that If your goal is to get a host variable into a shell running inside the container, you can do something like this example that launches bash inside the container with the host's TERM variable applied. lando ssh -c "sh -c 'TERM=$TERM bash'" |
Thank you for the info and the suggestion. What I really want is for plain |
The following suggests to me that this could be easily supported as config, given that
|
@phil-s im not sure if this is supported for |
My impression is that none of the current ways lando provides for using environment variables allow a value to actually be read from the inherited environment and propagated to the container command. They all seem to be "set VAR to a hard-coded value X" rather than "pass VAR with its current value to the container/command". Not only that, but the The |
@phil-s this is by design. as a rule we try to limit anything on the host polluting the environment in containers as a matter of stability. that said there are some obvious envvars we might want to forward along such as TERM, COLUMNS, etc, lando 4 will address that. right now lando 3 just piggybacks off of docker which sets environment variables at build time so a rebuild is required. in lando 4 we have "fast rebuilds" eg build steps are cached so the "cost" of resetting envvars and rebuiding should be lower. we also are looking into a more "dynamic" way to set envvars that DOES NOT require a rebuild and supporting envvars usage directly in the landofile. |
Sounds good, thanks @pirog. If it helps anyone else in the meantime, this is what I wrote as a wrapper: #!/bin/sh
# Force "lando ssh" (which does not involve ssh in any way!) to use
# the correct TERM environment variable. The idea for this came from
# https://github.com/lando/lando/issues/2188#issuecomment-1718218526
quote () {
local param
for param; do
printf %s "${param}Z" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/Z\$/' /"
done
}
if [ "$1" = "ssh" ]; then
shift
unset -v command help params
while [ $# -gt 0 ]; do
case "$1" in
( -h | --help ) {
help=1
};;
( -c | --command ) {
shift
command=$1
};;
( --command=* ) {
command=${1#--command=}
};;
( * ) {
params="${params}$(quote "$1")"
};;
esac
shift
done
if [ -z "${command}" ]; then
# No command; just run bash (by preference) or sh (otherwise).
# We use the same test that "lando ssh -vvv" shows normally.
shell="sh -c 'if type bash >/dev/null; then bash; else sh; fi'"
else
shell="sh -c $(quote "${command}")"
fi
# Apply the TERM environment variable.
shell="env TERM=${TERM} ${shell}"
# If --help was passed, don't use the shell command.
if [ -n "${help}" ]; then
params="ssh --help"
else
params="ssh -c $(quote "${shell}")${params}"
fi
echo "Command: lando ${params}"
eval "set -- ${params}"
fi
# Run the maybe-modified command.
/usr/local/bin/lando "$@" |
Hi !
Thanks you for this project, i use it with Laravel every day on Fedora since I've left Windows and Laragon.
My question is about connecting with ssh into the appserver without the lando CLI because i use Tinkerwell and it has remote support with ssh.
Since i don't want to install PHP on my local machine just for this it could be great to have a guide how to use ssh without the CLI.
Also I've noticed that my keys had been imported into the container so i might not be far from being able to connect with the container.
And here is a copy of my .lando.yml
The text was updated successfully, but these errors were encountered: