小编bk2*_*201的帖子

外部 IP 地址的 SSH 警报

所以我有一个脚本,如果登录名来自除以“10.1.”开头的 IP 地址之外的任何内容,它会向我发送电子邮件:

#!/usr/bin/python

import smtplib, os

server = "10.10.10.10"
From =  "address1@example.com"
to = ["address2@example.com"] # must be a list
subject = "SSH Login from outside network"

ip = os.environ['SSH_CONNECTION'].split()[0]
user = os.environ['USER']


if '10.1.' in ip:
    print "---SSH IP Check---"
    print 'Inside address, no alert will be sent.'
    exit(0)


text = user + " just logged in from " + ip

# Prepare actual message
message = """\
From: %s
To: %s
Subject: %s

%s
""" % (From, …
Run Code Online (Sandbox Code Playgroud)

login ssh monitoring

2
推荐指数
1
解决办法
2047
查看次数

在同一目录中创建文件的副本

假设我有一个包含以下文件的目录:

1.txt 2.txt 3.txt
Run Code Online (Sandbox Code Playgroud)

我想复制这些并基本上粘贴到同一目录中,制作新文件,例如:

1.txt 1(1).txt 2.txt 2(1).txt 3.txt 3(1).txt
Run Code Online (Sandbox Code Playgroud)

这比我想象的要难!这在 Windows 上似乎微不足道,只需突出显示一堆文件,复制/粘贴,它就会创建相同的文件,但在名称中添加“复制”。

shell cp

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

cp ×1

login ×1

monitoring ×1

shell ×1

ssh ×1