5篇 ssh related articles

虚拟机的安全配置(1)- 给SSH上把锁

前言

有段时间我用ssh远程登录后发现,有一串字符提示,大致意思的使用密码登录失败了几千次。登录的IP也是国内的国外都有。
看起来黑客想搞我的虚拟机,是在不断尝试啊。
目前在一家网络安全公司,虽说岗位不是安全研究之类的,但是一些安全意识也是增强不少,想起来是时候来关起门来了,把虚拟机一些整一下。

SSH 的安全设置

这里主要是sshd的配置文件/etc/ssh/sshd_config修改。

禁止root远程登录

PermitRootLogin no

禁用之后新建账号,以后用新建的账号远程登录,再切回root。

useradd aliang
passwd aliang

更换ssh端口号

Port 2222
一般也会被扫出来,只是让黑客能多费点事。

减少尝试登录次数

MaxAuthTries 3

一次登录时限为30秒

LoginGraceTime 30

仅使用密钥登录,不允许使用密码登录

PasswordAuthentication no
AuthorizedKeysFile .ssh/authorized_keys

生成密钥方法下一篇文章再说。

PAM参考这里

https://www.ibm.com/developerworks/cn/aix/library/au-sshlocks/index.html

More ~

为Ubuntu Server开启SSH

虚拟机安装的Ubuntu Server镜像,向导里需要设置用户账号,没有设置root密码.

1.登陆初始账号,修改root 密码
sudo passwd root

su切换root 试试

2.root 账号下修改配置文件
vi /etc/ssh/sshd_config
找到下面相关配置:

# Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes

更改为:

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

3.重启ssh
sudo service ssh restart

More ~