I added a user to run a specific service using the command:
sudo useradd -r -s /bin/false userName
I then try to run the service manually (after changing ownership of the service) by using:
su userName -c "./path/to/service"
Then I get a password prompt for which I do not know the password. I thought that system users weren't supposed to have passwords. What am I doing wrong here?
Related
I have an oracle database with password
+oS0pocWEpvaX++CN3]8nM‘2eX
If I try to connect with it using
sqlplus -S -L USER/'"+oS0pocWEpvaX++CN3]8nM‘2eX"'#host #script.sql
sqlplus -S -L USER/'+oS0pocWEpvaX++CN3]8nM‘2eX'#host #script.sql
sqlplus -S -L USER/"+oS0pocWEpvaX++CN3]8nM‘2eX"#host #script.sql
they all fail with error
ORA-01017: invalid username/password; logon denied
However the same password works in sql developer. How do I get sqlplus to work given that this password cannot be changed?
If you're using Linux, another idea to try would be to use a here-doc:
sqlplus << EOHD
CONNECT USER/+oS0pocWEpvaX++CN3]8nM‘2eX#host
#script
EXIT
EOHD
Login as SYS from the backend and reset the password of the user without any special characters.
Change it to a preferred password without special characters from your script.
Im trying to setup postgres database for my django project, so i donwnloaded the installer together with the pgadmin. i set a default password when installing and i used it to login to the pgadmin and it worked, i now wanted to run so cli commmand, so i added postgres to path in my system enviroment variable in other to be able to run it on the cli and it works, i mean the system recognise the commands but im getting errors which i think its comming from the database itself. i have no idea about this error, this is my first time using it.
PS: it asked for my system user password and i entered it, then i got the error bellow.
C:\Users\Davinci>psql
Password for user Davinci:
psql: error: FATAL: password authentication failed for user "Davinci"
Try running psql -U postgres and then inserting the password you chose at pgadmin.
User postgres is the default, but it seems like Windows is trying to run psql -U Davinci when you type only psql, so you have to specify which user (-U for user / postgres for the username) when trying to connect.
I have a nagios4 instance running in a container and based on "nagios4_inspect" file the credentials are:
"NAGIOSADMIN_USER=nagiosadmin",
"NAGIOSADMIN_PASS=nagios",
But when I go to the http://localhost/nagios and insert the credentials it doesn't accept it.
Am I doing something wrong?
Please go to below location and reset the password
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin/
Before apply the above command, please verify the file location of htpasswd.
I have create a new user in pgsql with no password. But when i try to create a database for this user it prompts for a password
>createuser -d -S -R -U postgres test1
Password:
>createdb -U test1 db1
Password:
i have tried the superuser password but it gives me the error :
createdb: could not connect to database template1: FATAL: password authentication failed for user "test1"
Please help,
Thank you
There is an alternative way to create user by prompting password.
You can give -P option while creating user.
Like:
createuser -d -S -R -U postgres test1
This may work for you,
psql -c "CREATE DATABASE mydb" "user=postgres dbname=postgres password=something_secret"
You need to run this from command-prompt. Go to the PostgreSQL folder where you can find the program psql and try this command. mydb would be the database name.
Reference: How to prevent asking for password when creating new database in PostgreSQL 10?
Thanks to: Jasen and Mladen Uzelac
I am trying to copy one table from one database to another:
sudo -u postgres pg_dump -t _stats db30 | psql db8;
However, I always get asked for a password, and I do not know what it is. Is there a way to do this without pg_dump? Is there a way so that I can not be asked for a password when I run psql?
Note, to get into postgres I have to run sudo -u postgres psql instead of psql
User management and permission on a postgres server is a complex topic, but you have probably only a server installed on your desktop and use it only on localhost, so security is not so important.
You have to do 3 steps:
1) Edit the pg_hba.conf file and restart the server
2) Login with psql and set a password for the user postgres
3) Edit (or create) the file ~/.pgpass
NOTE: you could use the authentication method trust in pg_hba.conf and avoid the step 2 and 3, but this is really TOO permissive, and you shouldn't use it, even on localhost.
The pg_hba.conf file
To understand the file pg_hba.conf please read here: http://www.postgresql.org/docs/9.4/static/auth-pg-hba-conf.html
Basically, if you server is on localhost and security does not matter, you can simply allow all user to connect with md5 authentication method.
If you don't know, where this file is, use this command:
locate pg_hba.conf
Probably is in /etc/postgresql/9.3/main/pg_hba.conf or similar.
Edit the file and change the already existing lines so (at end of the file):
local all all md5
host all all 127.0.0.1/32 md5
Now restart the server with
sudo service postgresql restart
Set a password for the user postgres
First login in psql:
sudo -u postgres psql
Now, within psql, change the password:
ALTER USER postgres PASSWORD 'your-password';
The pgpass file
Now you can login in psql with psql -U postgres (without sudo -u postgres) but have to enter the password. To avoid to digit the password every time, you can set up the pgpass file. If does not already exist, you must create a file named .pgpass in your home directory. The file must be owned by your user and be readable only by your user:
chown $USER:$USER ~/.pgpass
chmod 600 ~/.pgpass
Now write in the file those lines:
localhost:5432:*:postgres:your-password
127.0.0.1:5432:*:postgres:your-password
Alternately you can use the environment variable PGPASSWORD: http://www.postgresql.org/docs/9.4/static/libpq-envars.html
Ready. Now you can login in postgres with psql -U postgres without enter the password.