一次性口令OPIE


 口令用久了,就可能泄露,所以就有了一次性口令,用完就没用了。有没有想过强化一下你的ssh登陆呢?

  原理:服务器维护一个不断变化的口令列表,这个列表是算出来的。你每次用一个口令,用什么口令是预定好的,用过就失效,轮到下一个口令你不必非记住每个口令,登陆时,系统会给你提示,根据提示,再根据你事先知道的一个密码,在安全的客户端算出口令,再用其登陆。

  步骤:

  1.初始化:需要初始化要登陆的系统口令序列,在你要使用的帐户的提示符下:

  %opiepasswd -c -n 1000

  Adding eliumao:

  Only use this method from the console; NEVER from remote. If you are using

  telnet, xterm, or a dial-in, type ^C now or exit with no password.

  Then run opiepasswd without the -c parameter.

  Using MD5 to compute responses.

  Enter new secret pass phrase: xxxxx

  Again new secret pass phrase: xxxxx

  ID eliumao OTP key is 1000 el6652

  LOB COCO DISK FAIN CRAG CAM

  其中第一行中,-c是创建或初始化的意思,-n后面有个数字,是你要创建的口令序列的长度,用完还要重新初始化。默认是500个。

  第七行,输入你的密码,这个密码是用来以后根据系统提示算密码的,或用来重新初始化。密码复杂些没有坏处。

  第八行,再输入一遍密码。

  成功。

  下次想修改的话,直接用不带-c的命令就好了。

  2.配置sshd_config使ssh使用opie的方式验证口令

  (注意,如果你用的是6.0,那么就不用第2步的配置了!!!!!)

  请安装/usr/ports/security/openssh-portable。别忘了在/etc/rc.conf里加上这一行:

  sshd_program=”/usr/local/sbin/sshd

  /etc/ssh/sshd_config

  ————————————–

  ChallengeResponseAuthentication yes #这一行不要是no,默认是yes

  ————————————–

  3.配置PAM

  (如果你用的是6.0,那么就不用第3步的配置了,相关配置文件的位置/etc/pam.d/sshd!!!!!)

  以下是我的/etc/pam.conf中关于ssh的内容

  ——————————————————————————–

  # OpenSSH with PAM support requires similar modules. The session one is

  # a bit strange, though…

  #sshd auth sufficient pam_skey.so

  sshd auth sufficient pam_opie.so no_fake_prompts

  sshd auth requisite pam_opieaccess.so

  #sshd auth sufficient pam_kerberosIV.so try_first_pass

  #sshd auth sufficient pam_krb5.so try_first_pass

  sshd auth required pam_unix.so try_first_pass

  sshd account required pam_unix.so

  sshd password required pam_permit.so

  sshd session required pam_permit.so

  ———————————————————————————

  注意,第三行,我屏蔽掉了skey方式

  第四行,我设置成使用opie认证就足够了

  第五行,我设置成opie认证通过是必须的,如果你还希望通过普通口令(UNIX系统口令)登陆,就不要这一行。

  OK,大功告成。

  4.试试看

  %ssh ssh.eliumao.com

  otp-md5 451 gw0965 ext

  Password:

  这里的password是这样算的,在本地运行

  %opiekey 451 gw0965

  Using the MD5 algorithm to compute response.

  Reminder: Don’t use opiekey from telnet or dial-in sessions.

  Enter secret pass phrase: xxxxxxx

  REIN BONN WAYS FILL CALF BRAD

  注意,第一行,opiekey命令的参数就是ssh时这一行(otp-md5 451 gw0965 ext)得到的。

  第四行,输入步骤1时那个secret pass phrase。

  最后一行,得到的就是登陆要用的口令。

  5.注意事项

  显然,步骤1的那个口令的安全十分重要。产生时,最好通过安全的连接或者干脆就在服务器本地。算一次性口令时,也要注意是在安全的终端上

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3