ログイン
編集不可のページディスカッション情報添付ファイル
rand0m/memo/login-shell-motd

MMA

~/.ssh/configでRemoteCommandすると/etc/motdが表示されない話

解決方法

症状:

  • chshが出来ない
    以下の場合,/etc/motdが表示されない
  • ssh remote@example.com -t "zsh --login"としたとき
  • ~/.ssh/configが次のように設定されている場合
(中略)
    RequestTTY yes
    RemoteCommand zsh

以下の場合,/etc/motdが表示され
- ssh remote@example.com

迂回方法

  • ~/.zshrccat /etc/motdを追加
    cat /etc/motd
    (これはエレガントな解決方法ではないので,良くない)

もしかして理由:

もしかして,-t "zsh --login"がcommandとして認識されている(?)

https://github.com/openssh/openssh-portable/blob/master/session.c#L812

/*
 * 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の内容を出力しているのは誰?

rand0m/memo/login-shell-motd (最終更新日時 2022-04-12 14:41:46 更新者 rand0m)