1

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.

sobi3ch
  • 873
  • 1
  • 7
  • 11

1 Answers1

0

The MOTD is typicaLLY displayed by login, not bash, so if you don't run login you don't get MOTD. sshd probably doe not even use login, but does print motd 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"

infixed
  • 176
  • 4
  • 1
    Nope. Motd is print during the [session initialization in `sshd`](https://github.com/openssh/openssh-portable/blob/master/session.c#L930). – Jakuje Apr 22 '16 at 18:01
  • according to `man motd` it is emitted by `login(1)` I corrected my answer. – infixed Apr 22 '16 at 18:05
  • 1
    Yes, but `ssh(1)` is not running `login(1)`, unless you are using `UseLogin Yes` option in `sshd_config` (which is not advisable). – Jakuje Apr 22 '16 at 18:06
  • damn github's scripts slow my access down too much – infixed Apr 22 '16 at 18:17