I know that -t
option in ssh allocate pseudo-tty. I'm using -t
to "jump" to different directory on login, something like this:
ssh -t my-server "cd /path/to/my/directory; bash --login"
.
Why if I log in without it (normally) /etc/motd
is printed and with -t
it is not? I know I can cat /etc/motd
before cd
but wondering is there cleaner solution and WHY is happening like that at all.
ps: As You can imagine I want MOTD to be prited on login even if I use -t
.
The MOTD is typicaLLY displayed by
login
, notbash
, so if you don't runlogin
you don't get MOTD.sshd
probably doe not even uselogin
, but does printmotd
depending on the setting of several of its flags. (as noted by Jakuje ) The way you are connecting through sshd does not trigger the motd behavior.I suspect that trying to get things to run the way you want is going to be altering your profile file to do MOTD when bash is started by sshd. I suppose you can check to see if
$tty
is defined, but there will probably still be games to keep you from getting two MOTD on a real login.It really seems like a lot of effort for little gain.
Or, if you like
ssh -t my-server "cd /path/to/my/directory; cat /etc/motd; bash --login"