Share 一个反ssh爆破脚本的思路

近期遇到了一些手里有点资源的脚本小子,每天都在尝试爆破我的ssh密码:

我简单的统计了一下IP地址所在隶属的组织关系,目测大都是一些少有人维护的公有云主机,被日了之后成了某些脚本小子们手里的肉鸡,来源地大都是国外,不过也不保证是某些人买了国外的肉鸡。

之前有尝试过更改端口号,不过在写脚本的时候通用性不好,毕竟现在规模还太小了,没必要为此写一个cmdb,所以最终决定自行处理一下。

有人推荐使用fail2ban,考虑过,不过由于目前不需要考虑效率问题,而且量不是很大,所以决定先用一个简单的shell脚本来实现。

Continue reading
Posted in Linux, OS | Tagged , , , , , | Leave a comment

sudo 与重定向符号共用时出现permission denied的处理方案

由于之前在云厂商工作的关系,对于一次性批量操作不是很喜欢使用 ansible或者saltstack操作,而是爱用效率比较高的pssh。

当然,pssh所带来的弊端更多的会局限在sudo上,尤其是带密码的私钥和在使用重定向符号的时候报permission denied的情况,这次我们只share一下关于使用重定向符号return permission denied的解决方案。

# ssh [email protected] -x 'sudo echo " */5 *  *  *  *  user      /bin/bash /opt/auto/testing" >> /etc/crontab'
 bash: /etc/crontab: Permission denied

其实最简单的办法就是使用bash -c “” 将要sudo的命令包起来(注意,需要对引号进行转义):

ssh [email protected] -x 'sudo sh -c "echo \" */5 *  *  *  *  user      /bin/bash /opt/auto/testing\" >> /etc/crontab"'

看,单点添加成功了,把语句改成pssh即可。

Posted in AutomaticOPS, Linux, OS, SSH/PSSH | Tagged , , , , | Leave a comment

为kubectl增加插件

先下载配置文件和相应的tar包,并对tar包解压,释放出可执行文件:

wget https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz
wget https://storage.googleapis.com/krew/v0.2.1/krew.yaml
tar -zxvf krew.tar.gz
# wget https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz

--2020-01-13 08:34:35--  https://storage.googleapis.com/krew/v0.2.1/krew.tar.gz

Resolving storage.googleapis.com (storage.googleapis.com)… 172.217.164.112, 2607:f8b0:4005:807::2010

Connecting to storage.googleapis.com (storage.googleapis.com)|172.217.164.112|:443… connected.

HTTP request sent, awaiting response… 200 OK

Length: 14375157 (14M) [application/x-tar]

Saving to: ‘krew.tar.gz’

100%[=====================================================>] 14,375,157  42.9MB/s   in 0.3s
2020-01-13 08:34:36 (42.9 MB/s) - ‘krew.tar.gz’ saved [14375157/14375157]
Continue reading
Posted in Kubernetes, Platform | Tagged , , , , | Leave a comment

pssh使用带有密码的私钥登陆在使用-A参数之后报错

pssh使用带有密码的私钥登陆在使用-A参数之后报“tderr: Enter passphrase for key ‘****”

解决方法:
修改
vim /lib/python2.7/site-packages/psshlib/askpass_client.py

OS X为: 
vim /usr/local/Cellar/pssh/2.3.1/lib/python2.7/site-packages/psshlib/askpass_client.py

将第67行的:

if not prompt.strip().lower().endswith('password:'):

改为

if not ( prompt.strip().lower().endswith('password:') or 'enter passphrase for key' in prompt.strip().lower()):

Posted in AutomaticOPS, Linux, SSH/PSSH | Tagged , | Leave a comment

Hyper-V虚拟机安装

Install Hyper-V in windows 2008 R2 Enterprise Server Manager-add roles

Select Hyper-V

PS.Installation need reboot

Create virtual machineHyper-V manager

Action-New-Virtual Machine

Name of virtual machine

Memory

Network

Hard Disk

Install options

Summary

Tips: release mouse press”ctrl+alt+ ←” 补充以下 J, 下面Hyper-V成功安装 VM能正常运行是需要前提条件的 ,也就是你的硬件要支持虚拟化,需要在 BIOS中启用对虚拟化的支持。具体如下 :

  1. BIOS(RBSU) 中enable No-Execute, 如下图:
  2. BIOS 中启用Processor的 Virtualization,例如Intel Virtualization Technology 或者AMD  Virtualization(AMD-V),参考下图 (针对Intel processor) :

若上述没有启用会提示如下错误或者无法正常运行的提示信息 : the installer reports that the server does not contain the required hardware support或者The message will indicate that the virtual machine could not be started because the hypervisor is not running.或者cannot start the virtual machine

Posted in OS, Windows | Tagged , | Leave a comment