Tại công ty của tôi, khi tôi đăng nhập vào một số máy chủ, lần đăng nhập cuối cùng của tôi và một biểu ngữ lớn được hiển thị:
me@my-laptop$ 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 *
* admin@company.com *
************************************************************************
me@the-server$
Tất nhiên, tôi không muốn biểu ngữ khổng lồ này hiển thị mỗi khi tôi đăng nhập, nhưng tôi muốn giữ thời gian đăng nhập cuối cùng và máy chủ lưu trữ được hiển thị .
Nếu tôi sử dụng touch ~/.hushlogin, banner không được hiển thị nhưng tôi cũng mất
thông tin đăng nhập cuối cùng . Trong thực tế, không có gì được hiển thị:
ssh the-server
me@the-server$
Làm cách nào để xóa biểu ngữ nhưng vẫn giữ thời gian đăng nhập và lưu trữ cuối cùng, như thế này:
ssh the-server
Last login: Mon Feb 8 18:54:36 2016 from my-laptop.company.com
me@the-server$
last -w | grep "$USER" | head -n1 | perl -lane 'END{print "Last login: @F[3..6] $F[8] from $F[2]"}'vìlastlogđã cắt bớt tên máy chủ của tôi.