Contents
How can I run a script immediately after connecting via SSH?
Note how the script sets MY_SSH_CONNECTION=”yes” before tmux attach to pass it through to tmux as it also will be opening a shell that will access the very same script above and will prevent any recursion. This gives me some time to abort reattaching to or creating a screen session.
Why is my.bashrc calling my.ssh command?
So, essentially, because the shell was execing into zsh, ssh was waiting for this to finish – which never happened. I am a little confused why my .bashrc was being called at all – I thought this was only for interactive shells, but the exact purpose and order of the various init scripts is something I don’t think I’ll ever learn.
What happens when you run SSH example.com?
When you run ssh example.com, the ssh daemon starts a login shell for you, and the login shell reads your ~/.profile (or ~/.bash_profile or ~/.zprofile or ~/.login depending on your login shell). When you specify a command to run remotely (with or without -t ), the ssh daemon starts an ordinary shell, so your .profile is not read. Remedy:
What do I do when my ssh command hangs?
When I attempt to execute a command on a remote server with ssh, the ssh command hangs after the exec request accepted debug message, and eventually times out. The failing command: ssh -v -v @ uptime (also tried echo hello etc.)
How can I prompt for input in a Linux shell script?
I previously advised setting PermitUserEnvironment yes and adding an environment variable in your ~/.ssh/environment until Eli Heady chipped in with a better suggestion in the comments below. Open your .zlogin (bash: .bash_profile etc.) and put the following: Inspiration taken from: How do I prompt for input in a Linux shell script?
How can I run a script immediately using environment variables?
Remedy: Most ssh daemons are configured to refuse transmitting environment variables except for LC_*. If the ssh daemon on example.com allows it, you can abuse a custom LC_* variable to start tmux automatically — put this in your ~/.profile:
How to run bash script as a login shell?
One workaround is to change Gnome Terminal to load the shell as a login shell from it’s profile preferences, but then that would run every time you open up a new terminal window. Another option is to add it to the list of Startup Applications as suggested by @jrg. I’m going to paraphrase from another answer, but I’ll include all the basics.
Where can I find the original SSH command?
The command is invoked by using the user’s login shell with the -c option. This applies to shell, command, or subsystem execution. It is most useful inside a Match block. The command originally supplied by the client is available in the SSH_ORIGINAL_COMMAND environment variable.
Is there a way to keep SSH sessions running?
Using disown Command to Keep SSH Sessions Running. Another elegant way of letting your command or a single task run in background and remain alive even after session logout or disconnection is by using disown.
How to keep remote SSH running after logout?
Another elegant way of letting your command or a single task run in background and remain alive even after session logout or disconnection is by using disown.