Linux开启SSH登录email通知

Linux服务器通常需要远程登录访问,尤其是当服务器或VPS还允许root直接登录时,应该为SSH登录成功配置一个自动的email提醒。

sendmail直接发送的话很可能会发送到垃圾邮箱里,需要把地址加入到白名单。

把下面的admin@hackhp.com更改为你要接收登录通知的电子邮件地址。

CentOS

vim ~/.bash_profile
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")

echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' admin@hackhp.com

1.jpg

2.jpg

Ubuntu/Debian

vim ~/.bashrc
IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")

echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' | mail -s 'SSH Login Notification' admin@hackhp.com

如果不想接收到邮箱,只想重定向到一个文件的话。


IP="$(echo $SSH_CONNECTION | cut -d " " -f 1)"
HOSTNAME=$(hostname)
NOW=$(date +"%e %b %Y, %a %r")
echo 'Someone from '$IP' logged into '$HOSTNAME' on '$NOW'.' >>/root/login.txt

denyhosts 設定檔簡易說明

Step One—Install Deny Hosts

We need to use a repository to install Deny Hosts on CentOS.

sudo rpm -Uvh http://mirror.metrocast.net/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
sudo yum install denyhosts

Once the program has finished downloading to the VPS, denyhosts is installed and configured.

 

 

 

yum install denyhosts

http://blogger.liaohaha.tw/2012/02/denyhosts.html

Fortigate 60B 忘記密碼

久久沒開機的FG60B, 突然要借給別人使用,怎麼辦呢?

可以利用console 連接到設備

然後電源拔掉重新接上

登入帳號如下:

username:  maintainer
password: bcpbFGT60B1234567890

密碼部分為: bcpb+序號(設備背面都有FGTXXXXXXX)

登入後

修改admin密碼的方法:
#config system admin
#edit admin
#set password  [newpassword]

#end

 

#execute factoryreset