how to create first user in psycopg2 - python-3.x

I am trying to connect PSYCOPG2, however it is my first time doing so and I haven't created any user. All tutorials I see supose I have already created one and I simply can't connect. I have seen that there is a default user for Postgres and I have tried the following codes and received the following errors:
conn = psycopg2.connect(database="postgres", user="postgres", password="postgres", port=5432)
Error FATAL: password authentication failed for user "postgres"
con = psycopg2.connect(database='postgres', user='postgres')
Error fe_sendauth: no password supplied
What else should I try, please?

Some installers ask for a password during installation (really is used for initialization of the database after installation of the software), then you need to specify this password to connect as the 'postgres' user, even from the local machine. This is common for Windows installers. If you don't remember what you told it, it might be easiest just to reinstall.
Linux installers are not likely to do this, they usually use 'peer' method with no password. But this only applies when you use a unix-domain socket to connect. Your python code suggests that that is what you are doing (since that is usually the default on linux when no host is provided), but the log-file message suggest you specified the host of ::1 to connect to.

Related

Application unable to connect to mongodb on DigitalOcean droplet

From the terminal, the application launches and connects with MongoDB, but when I attempt to access it at the IP address of the droplet (with the correct port), I am getting an error:
MongoError: not authorized on cmf to execute command (cmf is the dbname).
I followed the install & setup instructions here, creating a user and afterward added the role of root described here. This was for the admin database.
When logged into the Mongo shell, I can access data thru db.status(), and when using admin db I can run show users and see the user.
I am confused whether I lack configuration for the cmf database. When using cmf db, when I run show users, nothing is returned.
For unknown reasons, the application cannot connect with mongodb. I am now thoroughly confused about where to go from here.
If anyone can point me in the right direction, I would appreciate it.
You need to create the database user with password (like in the tutorial included in your question), then upon connecting:
var dbHost = 'mongodb://username:password#localhost:port/cmf';
mongoose.connect(dbHost);
Where:
username is the username of created user,
password is the password,
port is the correct port of running mongodb (defaults to 27017).

Error 1312 from net use when mapping samba share

I have written a service that monitors if my app is running and starts it if not. In result the app is run as a "system" user - which is the way I want it to be. I have several of those installations working properly.
The app should mount a network share that is in this case available on a linux samba server. The problem is that when running the command:
net use X: \\IP\share_name /user:login password
an error is displayed:
System error 1312 has occured.
A specified logon session does not exist. It may already have been
terminated.
I have run some checks and it turns out that the X: drive in local system is available, the server is online, the share is available, the credentials are OK, there are no other net use sessions running in this system. Also I have found out a strange behavior: running identical command as a standard user gives proper results and the drive is mounted properly.
Do you have any suggestions what might be the problem and how to solve it?
Additionally I am not a domain member, and the system that shows the error is Windows 7 Pro. I have other machines in the same network that do work properly without the error.
I have had the same issue some time ago. It helped when I introduced a domain name (even if you are not a domain member) before the login.
I your case try this command:
net use X: \\IP\share_name /user:whatEver\login password
Test this command:
EXEC XP_CMDSHELL 'net use Z: 192.168.3.55backupShare password#123 /User:domainuser'
I've just run into the same problem on upgrading to Windows 10 PE 2004 (19041). The older Windows 10 PE 1803 (17134) did not require the dot before the username.
Here's the solution:
Put the password before the user (this is the argument order given by net use /?).
Add the server's name, IP or a dot and then a backslash (.\) before the username .
Use:
net use X: \\IP\share_name password /user:.\login
or
net use X: \\IP\share_name password /user:IP\login
If you have arguments with spaces, add parenthesis around them:
net use X: "\\IP\share name" "pass word" /user:".\test user"

CUPS session setup failed with 'nt_status_logon_failure'

I am running the CUPS in Linux Debian machine. Using the CUPS I am sending the print request to Windows XP machine. I have enabled the 445 and 139 port and I am able to connect the Windows Machine. Printer is connected to the Windows Machine.
I am sending the print request using the following command
lp -E -d < Printer Name > file name.
After sending I am checking the printer status using the following command
lpstat -p < Printer Name >
I am getting the below error message when I execute the above message.
unable to connect to cifs host will retry in 60 seconds..
When I checked in the log I am getting the below error message.
session setup failed: NT_STATUS_LOGON_FAILURE and NT_STATUS_BAD_NETWORK_NAME
The DeviceURI is like below in /etc/cups/printers.conf
smb://username:password#IP Address of windows Machine/printer_Name
Please let me know if the password is having '#' symbol, how can we specify the '#' with actual syntax in DeviceURI ( user:password#IP )
Unfortunately you provide not enough detailed info about your specific setup. So I will make an effort to take several potential problems into account and give hints how to overcome them:
I.
Did you use the correct share name for your shared Windows printer?
To find out, use this command:
$ smbtree -U windowsusername
You might see something like the following output:
WORKGROUP
\\MURUGA-PC
\\MURUGA-PC\G
\\MURUGA-PC\Z
\\MURUGA-PC\Public
\\MURUGA-PC\print$ Printer Drivers
\\MURUGA-PC\EPSON Stylus CX8400 Series EPSON Stylus CX8400 Series
In other words: your printer's share name may contain spaces. But you cannot use spaces in the device URI for CUPS! What now?
Easy: (1) Either rename the share name on the Windows side. (2) Or escape the space by using %20 instead:
smb://muruga:mysecretpassword#muruga-pc/EPSON%20Stylus%20CX8400%20Serie
II.
Is your Windows XP by any chance using Kerberos authentication? For example, because it is part of an Active Directory environment? Then you should refer to this document on cups.org:
Configuring CUPS to Use Kerberos
Kerberos authentication does not work with username/password, it uses 'tickets'.
III.
Otherwise, if your Windows XP machine is part of a "standard" domain, you may be more successful by ditching your device URI of smb://username:password#ip-address-of-windows/printer_name and use this instead:
smb://username:password#domain_name/windows_host/printer_Name
The username you use has to be the Windows user name (with his/her password) who installed the printer on Windows!
IV.
Alternatively, you may have success by using IPP to print to Windows (though XP needs an IPP-enabling extension installed, provided by Microsoft). Be aware that MS is using a non-standard syntax for their device URIs (using port 80 or 443), and their version of IPP is still 1.0 (which always remained in "draft" status and never made it into an official release by the IETF):
DeviceURI https://mywindowsprintserver/printers/printername/.printer
or
DeviceURI http://mywindowsprintserver/printers/printername/.printer
For username/password authentication to this printer, you need
AuthInfoRequired username,password in /etc/cups/printers.conf and
DefaultAuthType Basic in cupsd.conf.
To use Kerberos, you need
AuthInfoRequired Negotiate in /etc/cups/printers.conf and
DefaultAuthType Negotiate in cupsd.conf.
If the whole setup is in a household with a private LAN/WLAN, you may want to consider removing all access controls (first on the Windows print server side, then):
AuthInfoRequired None in /etc/cups/printers.conf and
DefaultAuthType None in cupsd.conf.
If your problem is that your password contains a '#'-character, then try this:
smb://username:'p#ssword'#domain_name/windows_host/printer_Name
or
smb://username:p%40ssword#domain_name/windows_host/printer_Name

Why am I getting SSL_read errors and Rpc_client_frag_read errors when trying to Remote Desktop

I'm trying to set up a remote desktop session for monitoring specific systems at my place of work. I only have access to a Linux machine and I need to connect via a terminal server gateway. I am using FreeRDP to do this and i am using the following command to create the connection:
xfreerdp /d:** /u:***** /p:******* /g:******.************.***
/v:****.*********.***** /port:3389 /size:1920x1080
I have hidden all connection details per my supervisors request however both he and I verified the correct information is entered into the fields.
When I send the connection through I get the following error:
Connected to ******.************.***:443
Connected to ******.************.***:443
TS Gateway Connection Success
Got stub length 4 with flags 3 and called 7
Got stub length 4 with flags 3 and called 6
SSL_read: I/O error: connection reset by peer (104)
Rpc_client_frag_read: error reading header
Would anyone have any idea of what I might be missing? I have even tried adding
/sec:rdp
to the script and even that produced the same error
Try rdp from a Windows system (or have someone else try from their system, since you don't have direct access to Windows). I know it won't solve your problem, but it may give you better information. I'm in a similar situation and got the same error message. I tried remmina instead of xfreerdp and got even less information than xfreerdp spits out.
From a Windows VM, at least I could tell when I got my domain\username & password right -- it told me my account was not allowed rdp access to that server. I'm figuring that means that there are accounts that can rdp in, but mine is not among them. Along the way, though, I found that the remote was using a certificate from an untrusted authority, which was useful information for my case.
If your Linux is old or hasn't been updated, do so. Your certificate store may be out of date. But it may also be that your company's Windows domain has certificates that Linux doesn't know about. It could be a simple matter that you're lacking the company-supplied cert (because they push it to all Windows machines on the domain, but your Linux machine doesn't get that "benefit").

How to log into SmartDashBoard?

I installed the CheckPoint SecurePlatform R75.20 on my VirtualBox. I configured it. Now in order to create an OPSEC Application and proceed to maintaining a LEA server, i need to login to SmartDash Board. I define me (i.e my ip) as a GUI client, and tried to login to the SmartDash Board using the administrator usename and password (this is what needs to be done). But the login gets rejected saying "either host is dowm or user not a GUI client". In my case, host is up, as im ssh'ing into it and i have clearly mentioned my ip as a GUI client.
Where have i gone wrong?
Thanks.
To be able to logon to a CheckPoint SmartCenter you will have to;
Have network access to TCP port 18190 (CPMI) from your machine to the SmartCenter (which you probably have since its on your own LAB-network).
A username/password, which you created during the installation or can add or modify later using the command "cpconfig" and going to menu option "Administrator". (Note: only 1 administrator can be defined using cpconfig. Future administrators is defined inside SmartDashboard).
Your IP-address must be in the GUI client list. You can modify this by logging on to the SmartCenter machine with SSH, enter command "cpconfig" and go to menu option "GUI Clients".

Resources