在脚本中保存密码 [英] Save passwords in scripts

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

问题描述

您好,

我有一个脚本,允许用户有限地操纵数据库。这个

脚本当然需要保存数据库连接的密码。另一方面,

用户需要对脚本具有读取权限才能执行它但不应该读出密码。

解决这个问题的常用方法是什么?


我目前的方法是允许用户使用sudo执行脚本,而

没有作为普通用户时的读取权限。但我不喜欢

这个解决方案,并认为它非常难看。


谢谢,

Florian

Hello,
I''ve a scripts that allows limited manipulation of a database to users. This
script of course needs to save a password for the database connection. The
users, on the other hand need read permission on the script in order to
execute it but should not be able to read out the password.
What is the common way to solve this problem?

My current way is to allow the users to execute the script with sudo while
not having read permission when acting as a ordinary user. But I don''t like
this solutions and consider it very ugly.

Thanks,
Florian

推荐答案

Florian Lindner写道:
Florian Lindner wrote:
我有一个允许对用户有限操作数据库的脚本。这个
脚本当然需要保存数据库连接的密码。另一方面,
用户需要对脚本具有读取权限才能执行它但不能读出密码。
解决此问题的常用方法是什么?


常见的方法是做一些构思错误和不安全的事情。


正确的方法是使用一种安全技术

不涉及自己存储密码,而是

而是存储它们的哈希版本(例如MD5或SHA),

或要求用户在需要信息时输入他们的密码



我目前的方式是允许用户使用sudo执行脚本,而
没有读取权限作为普通用户时。但我不喜欢这个解决方案,并认为它非常难看。
I''ve a scripts that allows limited manipulation of a database to users. This
script of course needs to save a password for the database connection. The
users, on the other hand need read permission on the script in order to
execute it but should not be able to read out the password.
What is the common way to solve this problem?
The common way is to do something ill-conceived and insecure.

The correct approach is to use a secure technique that
does not involve storing the passwords themselves, but
instead storing a hash version of them (e.g. MD5 or SHA),
or by requiring the users to enter their passwords at
the time the information is required.
My current way is to allow the users to execute the script with sudo while
not having read permission when acting as a ordinary user. But I don''t like
this solutions and consider it very ugly.




明确存储密码总是很丑陋和

不安全。想想用户

(不明智地)选择他也使用的密码的情况,

,他的网上银行。如果密码以明确的方式存储

,那么任何拥有超级用户权限的人都可以看到

它,即使你信任所有管理员,

或者自己是唯一的管理员,让管理员看到用户的密码仍然不是一个好主意。


-Peter



Storing passwords in the clear is always ugly and
insecure. Think about the situation where a user
(unwisely) picks a password that he also uses for,
say, his online banking. If the password is stored
in the clear, then anyone with root access can see
it and even if you trust all your administrators,
or are the only admin yourself, it''s still not a
good idea to let an admin see a user''s password.

-Peter


Peter Hansen写道:
Peter Hansen wrote:
Florian Lindner写道:
Florian Lindner wrote:
我有一个脚本允许对用户进行有限的数据库操作。
这个脚本当然需要为数据库保存密码
连接。另一方面,用户需要对
脚本具有读取权限才能执行它,但不应该读出
密码。解决这个问题的常用方法是什么?
I''ve a scripts that allows limited manipulation of a database to users.
This script of course needs to save a password for the database
connection. The users, on the other hand need read permission on the
script in order to execute it but should not be able to read out the
password. What is the common way to solve this problem?



常见的方法是做一些构思错误和不安全的事情。

正确的方法是使用安全技术
不涉及存储密码本身,而是存储它们的哈希版本(例如MD5或SHA),
或要求用户输入密码
需要信息的时间。



The common way is to do something ill-conceived and insecure.

The correct approach is to use a secure technique that
does not involve storing the passwords themselves, but
instead storing a hash version of them (e.g. MD5 or SHA),
or by requiring the users to enter their passwords at
the time the information is required.




哈希无法工作,因为我需要将密码提供给数据库服务器。我的

脚本是客户端,而不是服务器。它不会检查用户提供的密码

,只需使用硬编码密码连接到数据库服务器。



Hashes could not work, since I need to give the password to a DB server. My
script is the client, not the server. It does not check passwords supplied
by the users, just use the hard-coded password to connect to the DB server.

我目前的方法是允许用户使用sudo执行脚本
,而在作为普通用户时没有读取权限。但是我不喜欢这个解决方案,并认为它非常难看。
My current way is to allow the users to execute the script with sudo
while not having read permission when acting as a ordinary user. But I
don''t like this solutions and consider it very ugly.



以明文形式存储密码总是很难看,而且不安全。想想用户(不明智地)选择他也用于网上银行的密码的情况。如果密码以明文形式存储,那么任何拥有超级用户权限的人都可以看到
它,即使你信任所有的管理员,
或者自己是唯一的管理员,它仍然是不是让管理员看到用户密码的好主意。



Storing passwords in the clear is always ugly and
insecure. Think about the situation where a user
(unwisely) picks a password that he also uses for,
say, his online banking. If the password is stored
in the clear, then anyone with root access can see
it and even if you trust all your administrators,
or are the only admin yourself, it''s still not a
good idea to let an admin see a user''s password.




这不是用户密码。它是一个db用户的密码,它拥有几个

系统表,用户应该能够以

约束的方式操作它们。


我完全同意你的看法。这就是为什么我正在寻找更好,更安全的

解决方案。


Florian



It''s not a users password. It''s a password of a db user which owns several
system tables and the users should be able to manipulate them in a
constrained manner.

I fully agree with you. That''s why I''m looking for a better, more secure
solution.

Florian

Florian Lindner写道:
Florian Lindner wrote:
您好,我有一个脚本允许对用户有限的数据库操作。这个
脚本当然需要保存数据库连接的密码。另一方面,
用户需要对脚本具有读取权限才能执行它但不能读出密码。
解决此问题的常用方法是什么?

我目前的方法是允许用户使用sudo执行脚本,而
在作为普通用户时没有读取权限。但我不喜欢这个解决方案,并认为它非常难看。

谢谢,
Florian
Hello,
I''ve a scripts that allows limited manipulation of a database to users. This
script of course needs to save a password for the database connection. The
users, on the other hand need read permission on the script in order to
execute it but should not be able to read out the password.
What is the common way to solve this problem?

My current way is to allow the users to execute the script with sudo while
not having read permission when acting as a ordinary user. But I don''t like
this solutions and consider it very ugly.

Thanks,
Florian




哪个DB? afaik postgre有用户级认证,这意味着你

甚至不需要密码。


/ Esben



Which DB? afaik postgre has user-level authentication which means you
don''t even need a password.

/Esben


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

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