My purpose is to use mkdir on the remote host.
In the ssh man page which, on Ubuntu, comes from BSD, it says
If command is specified, it is executed on the remote host instead of a login shell.The command would be the one at the end of this:
ssh user@remoteHost command
For my purpose the command would be mkdir --parents path/folder. What is the significance of the phrase "it is executed on the remote host instead of a login shell"?
What does this mean? Does it mean that a non-login shell is used? My understanding is that both login and non-login shells involve .bashrc and so the difference is that the profile is not sourced for a non-login shell. Why would we want to ignore the profile of user?
1 Answer
Does it mean that a non-login shell is used?
Yes. (Depends on what you mean by "login shell", though.)
My understanding is that both login and non-login shells involve .bashrc and so the difference is that the profile is not sourced for a non-login shell.
Incorrect. A login bash reads .profile, and as it happens, Ubuntu's .profile sources .bashrc. A non-login, interactive bash reads .bashrc. A non-login, non-interactive bash invocation does not read .bashrc (or .profile, for that matter).
When you run ssh foo command, the command is run by a non-interactive shell. However, a non-login shell run by SSH is a special case, and bash reads .bashrc. Other shells may or may not read their respective rc files, so it could be the case for some shells that no configuration file is read at all. Bash is not the be-all and end-all of shells.
Non-interactive shells are run for a number of reasons, and usually there's no reason to load the full set of customizations set by a user.
Why would we want to ignore the profile of user?
See above. Also, SSH has other ways to set environment variables.