私の会社では、いくつかのサーバーにログインすると、最後のログインと巨大なバナーが表示されます:
[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
ができるようになりました 引き続きそのメッセージが表示されます。