GNU/Linux >> Linux の 問題 >  >> Linux

Bash .hushlogin、最後のログイン時間とホストを保持しますか?

私の会社では、いくつかのサーバーにログインすると、最後のログインと巨大なバナーが表示されます:

[email protected]$ ssh the-server
Last login: Mon Feb  8 18:54:36 2016 from my-laptop.company.com 
************************************************************************
*                                                                      *
*       C O M P A N Y    I N F O R M A T I O N   S Y S T E M S         *
*                                                                      *
* !WARNING!         Your connection has been logged          !WARNING! *
*                                                                      *
* This system is for the use of authorized personnel only.             *
* Individuals using this *computer system without authorization,       *
* or in excess of their authority as determined by the Company         *
* Code of Ethics and  Acceptable Use Policy, are subject to having all *
* of their activities on this system monitored, recorded and/or        *
* terminated by system personnel.                                      *
* If such monitoring reveals possible evidence of criminal  activity,  *
* Company may provide said evidence to law enforcement officials,      *
* in compliance with its confidentiality obligations and all           *
* applicable national laws/regulations with regards to data privacy.   *
*                                                                      *
*      This device is maintained by Company Department                 *
*                  [email protected]                                   *
************************************************************************
[email protected]$ 

もちろん、ログインするたびにこの巨大なバナーを表示したくはありませんが、最後のログイン時間とホストを表示したままにしておきたい

touch ~/.hushloginを使用する場合 、バナーは表示されませんが、
最後のログイン情報も失われます 。実際、何も表示されません:

ssh the-server
[email protected]$

バナーを削除し、最後のログイン時間とホストを次のように保持するにはどうすればよいですか:

 ssh the-server
 Last login: Mon Feb  8 18:54:36 2016 from my-laptop.company.com
 [email protected]$

承認された回答:

1つの方法は、以下を~/.ssh/rcに追加することです。 、マシンにSSH接続したときに実行されるコマンドが含まれています:

lastlog -u $USER | perl -lane 'END{print "Last login: @F[3..6] $F[8] from $F[2]"}'

このコマンドは、lastloginから最後のログイン時刻を取得します 次に、元のバージョンのようにフォーマットします。 touch ~/.hushloginができるようになりました 引き続きそのメッセージが表示されます。


Linux
  1. Bash +セカンダリスクリプトとメインスクリプトの両方を終了する方法は?

  2. CLOCK_REALTIME と CLOCK_MONOTONIC の違いは?

  3. Bash - 日付コマンドとスペース

  1. Bash履歴で実行する各コマンドの日付と時刻を設定する

  2. BashForループガイドと例

  3. ログイン後に bash スクリプトを実行する

  1. ログインシェルと非ログインシェルの違いは?

  2. &&および||後のBashラインの継続文書化されていますか?

  3. Linuxのrebootおよびshutdownコマンド