私は、バナー/motd の表示に関して一貫性のない動作をする Solaris 10 サーバーのファームで作業しています。
今回は、あるサーバーから別のサーバーに scp を実行しようとしています。一部のサーバーではバナーが表示されず、一部のサーバーではバナーが表示されます。
すでに試しました:
- .hushlogin ファイルの作成
- SCP-q は
- scp -o ログレベル=エラー
- /etc/ssh/sshd_config に PrintMotd がありません
- /etc/ssh/ssh_config の LogLevel QUIET
ssh を使用するときにはバナーが表示されなくなりましたが、scp のバナーは一部のサーバーでまだ表示されるので、これをオフにする方法を見つけたいと思います。
管理者権限はありませんが、特定の構成の変更をリクエストすることはできます。
SCP セッションのサンプル:
usera@server20$ scp a.sh server43:/tmp
###################################################################
# This system is for the use of authorized users only. #
# Individuals using this computer system without authority, or in #
# excess of their authority, are subject to having all of their #
# activities on this system monitored and recorded by system #
# personnel. #
# #
# Anyone using this system expressly consents to such monitoring #
# and is advised that if such monitoring reveals possible #
# evidence of criminal activity, system personnel may provide the #
# evidence of such monitoring to law enforcement officials. #
###################################################################
WARNING: Access to this computer system is limited to authorised users only.
Unauthorised users may be subject to prosecution under the Crimes
Act or State legislation.
a.sh 100% |***********************************************************************************************************| 602 00:00
usera@server20$
ファーム内のサーバーからの SSH セッションのサンプル:
usera@server20$ ssh server43
LI002: usera is allowed 2 concurrent logins
Last login: Tue Jun 16 2015 17:30:05 from pts/2
server43:usera>
ファーム外からの SSH セッションのサンプル:
login as: usera
###################################################################
# This system is for the use of authorized users only. #
# Individuals using this computer system without authority, or in #
# excess of their authority, are subject to having all of their #
# activities on this system monitored and recorded by system #
# personnel. #
# #
# Anyone using this system expressly consents to such monitoring #
# and is advised that if such monitoring reveals possible #
# evidence of criminal activity, system personnel may provide the #
# evidence of such monitoring to law enforcement officials. #
###################################################################
WARNING: Access to this computer system is limited to authorised users only.
Unauthorised users may be subject to prosecution under the Crimes
Act or State legislation.
Using keyboard-interactive authentication.
Password:
LI002: usera is allowed 2 concurrent logins
Last login: Tue Jun 16 2015 18:40:41 from pts/1
server43:usera>
答え1
この SSH サーバーは、希望するアプローチだけでなく、通常の SSH シェル セッションも実行していることを示していますsftp
。また、次の回答は、可能な限り古い OpenSSH バージョンに適用されますv4.0.0p1
(特に明記されている場合を除く)。この回答は、OpenSSH v6.6p1、REV=2014.03.20 を使用している最新の Solaris 10 および 11 に適用されます。
私のソリューションでは、通常の SSH とscp
/ の両方が提供されますsftp
。
設定
コツは、Match User sftp
SSH サーバー構成でいくつかの設定を使用することです。
Banner
PrintMotd
Banner
Banner
設定は、認証が許可される前にリモート ユーザーに送信される指定されたファイルの内容のファイル名です。引数が の場合、none
バナーは表示されません。デフォルトでは、バナーは表示されません。
OP に基づくと、おそらくBanner yes
ファイルのどこかに記述があり、その設定行を変更せずにその動作を制限できるため、問題ありません (これについては後で詳しく説明します)。
PrintMotd
PrintMotd
sshd(8)
ユーザーが対話的にログインしたときにを印刷するかどうかを指定します/etc/motd
。(一部のシステムでは、シェル、/etc/profile、または同等のものによっても印刷されます。) デフォルトは ですyes
。
おそらく設定ファイルPrintMotd <anything>
には記載されていないsshd_config
ため、デフォルトでは常に「今日のメッセージ」が表示されます。
設定ブロック
問題を解決するために、この SFTP/SCP アクティビティのユーザー名が であると仮定しますsftp
。
すべてのsftp
ユーザーにバナーや今日のメッセージ (MotD) が表示されないようにするために貼り付けて使用する設定ブロックは次のとおりです。
Match User sftp
Banner none
PrintMotd no
設定の配置
上記の設定ブロックは、次のいずれかのファイル名に含まれます。
/etc/ssh/sshd_config
(OpenSSH v7.3以前を使用している古いディストリビューション、およびmacOS
12 モントレーバージョン)/etc/ssh/sshd_config.d/900-custom-match-sftp.conf
(2016年以降のOpenSSH v7.3以降)
まれ: 可能性は低いですが (システム管理が複雑であるか、企業環境である場合を除く)、上記の設定ブロックは、、、またはブロックのMatch user sftp
前に配置し、読み取る必要があります。Match all
Match canonical
Match final
注: 複数ファイルの SSH サーバー構成は、ASCII 順序でロードします/etc/ssh/sshd_config.d
。複数ファイル構成アプローチでは、適切な読み取り順序を確保するために、開始ファイル名として 2 桁または 3 桁の数字を使用するのが一般的です。設定ブロックは、、、またはのMatch user
前に配置する必要があるため、およびが他の // 設定ブロックによって取得されると仮定すると、番号はそれらの前になります。Match all
Match canonical
Match final
970-*
97-*
9[7-9]-*
9[7-9][0-9]-*
canonical
final
all
SSHサーバーを再読み込み/再起動する
次に、SSH サーバーをリロード/再起動します。
次回scp
のsftp
ログイン試行では、その日のバナーやメッセージは表示されなくなります。
答え2
このオプションを試しましたか: -o LogLevel=quiet