如何在Perl脚本中加密或隐藏密码? [英] How can I encrypt or hide passwords in a Perl script?

查看:409
本文介绍了如何在Perl脚本中加密或隐藏密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用使用 Expect 的Perl脚本通过telnet登录到远程机器(don不要问,必须使用telnet)。我还根据需要执行perforce p4登录操作,并使用期望管道输入正确的密码。现在我只是从清晰的文本环境变量中读取密码,即 export PASSWORD = password ,我知道这是不安全的。

I am working on Perl script that uses Expect to login via telnet to remote machines (don't ask, gotta use telnet). I also do perforce p4 login operations as necessary and use expect to pipe in the correct passwords. For now I just read passwords from clear text environment variable, i.e. export PASSWORD=password, which I know is no good security wise.

为多个系统需要大量密码的脚本存储密码的最佳方式是什么?加密在一个文本文件不知何故?还有别的什么?

What's the best way to store passwords for scripts like these that need a lot of passwords for multiple systems? Encrypted in a text file somehow? Or something else?

请记住,我不能轻易地更改现有的系统,例如我无法真正安装SSH或任何类似的东西。 >

Keep in mind I can't easily change the existing systems, like for example I can't really install SSH or anything like that.

推荐答案

可能最好的方法是将密码放在一个单独的文件中,并锁定该文件的安全性,只有您有读取权限。不幸的是,如果您在脚本中存储加密密码,那么还需要存储解密方法,因此攻击者可以运行解密并恢复密码。

Probably your best way is to put the passwords in a separate file, and lock the security for that file down so only you have read access. Unfortunately, if you store an encrypted password in your script, you'll also have to store the decryption method, so an attacker can run the decryption and recover your password.

这篇关于如何在Perl脚本中加密或隐藏密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆