## page was renamed from rand0m/login-shell-motd #format gfm # ~/.ssh/configでRemoteCommandすると/etc/motdが表示されない話 ## 解決方法 - `chsh`ができる場合,`chsh`をする - あなたがMMAに所属している場合,次のリンクを参照して解決できる(非ログインユーザーには非表示) https://wiki.mma.club.uec.ac.jp/rand0m/login-shell-motd/MMA - `chsh`が出来ない場合,下の[迂回方法](#迂回方法) をとる ## 症状: - `chsh`が出来ない 以下の場合,`/etc/motd`が表示され**ない** - `ssh remote@example.com -t "zsh --login"`としたとき - `~/.ssh/config`が次のように設定されている場合 ``` (中略) RequestTTY yes RemoteCommand zsh ``` 以下の場合,`/etc/motd`が表示され**る** - `ssh remote@example.com` ## 迂回方法 - `~/.zshrc`に`cat /etc/motd`を追加 `cat /etc/motd` (これはエレガントな解決方法ではないので,良くない) ## もしかして理由: もしかして,`-t "zsh --login"`がcommandとして認識されている(?) https://github.com/openssh/openssh-portable/blob/master/session.c#L812 ```c /* * Check for quiet login, either .hushlogin or command given. */ int check_quietlogin(Session *s, const char *command) { char buf[256]; struct passwd *pw = s->pw; struct stat st; /* Return 1 if .hushlogin exists or a command given. */ if (command != NULL) return 1; snprintf(buf, sizeof(buf), "%.200s/.hushlogin", pw->pw_dir); #ifdef HAVE_LOGIN_CAP if (login_getcapbool(lc, "hushlogin", 0) || stat(buf, &st) >= 0) return 1; #else if (stat(buf, &st) >= 0) return 1; #endif return 0; } ``` ## 参考: 1. [/etc/motdの内容を出力しているのは誰?](https://debimate.jp/2020/12/01/%e3%80%90lpic%e3%81%a7%e8%a6%8b%e3%81%9f%e3%80%91-etc-motd%e3%81%ae%e5%86%85%e5%ae%b9%e3%82%92%e5%87%ba%e5%8a%9b%e3%81%97%e3%81%a6%e3%81%84%e3%82%8b%e3%81%ae%e3%81%af%e8%aa%b0%ef%bc%9f%e3%80%90/)