Microsoft SQL Server Installation error(PArrot OS) - sql-server

I have been trying to install microsoft SQL server on my lInux machine but it keeps throwing the same error, even after following the instructions given here on this platform.
When I run:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
It throws this error:
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 95, in <module>
sp = SoftwareProperties(options=options)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 103, in __init__
self.sourceslist = SourcesList()
File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 276, in __init__
self.refresh()
File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 292, in refresh
self.matcher.match(source)
File "/usr/lib/python3/dist-packages/aptsources/sourceslist.py", line 484, in match
if (re.search(template.match_uri, source.uri) and
File "/usr/lib/python3.9/re.py", line 201, in search
return _compile(pattern, flags).search(string)
File "/usr/lib/python3.9/re.py", line 304, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/lib/python3.9/sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "/usr/lib/python3.9/sre_parse.py", line 948, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/lib/python3.9/sre_parse.py", line 443, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "/usr/lib/python3.9/sre_parse.py", line 834, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "/usr/lib/python3.9/sre_parse.py", line 443, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "/usr/lib/python3.9/sre_parse.py", line 834, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "/usr/lib/python3.9/sre_parse.py", line 443, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "/usr/lib/python3.9/sre_parse.py", line 668, in _parse
raise source.error("nothing to repeat",
re.error: nothing to repeat at position 2
and when I run:
sudo apt install mssql-server
It throws the following error:
The following packages have unmet dependencies:
mssql-server : Depends: libssl1.0.0 but it is not installable
E: Unable to correct problems, you have held broken packages.
I am unable to install libssl1.0.0 since its already in its latest version, libssl1.1
What do I do??
The output for cat /etc/debian_version is parrot
And output of cat /etc/os-release is
PRETTY_NAME="Parrot OS 5.0 (Electro Ara)"
NAME="Parrot OS"
VERSION_ID="5.0"
VERSION="5.0 (Electro Ara)"
VERSION_CODENAME=ara
ID=parrot
ID_LIKE=debian
HOME_URL="https://www.parrotsec.org/"
SUPPORT_URL="https://community.parrotsec.org/"
BUG_REPORT_URL="https://community.parrotsec.org/"

ParrotOS is a Linux distribution based on Debian with a focus on security, privacy and development. You might want to check your reasons for installing SQL Server on it, perhaps you might wish to use a different distro.
The following shows how you can install Microsoft SQL Server 2019 on a ParrotOS 5.0 (ara) Docker container...
./docker-compose.yml:
version: "3.8"
services:
parrot:
build: parrot
container_name: parrot
environment:
- "ACCEPT_EULA=Y"
- "SA_PASSWORD=StrongPassw0rd"
ports:
- "1433:1433"
./parrot/Dockerfile:
# REFs:
# 1. Parrot on Docker
# https://parrotsec.org/docs/parrot-on-docker.html
# 2. SQL Server on Linux
# https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-overview
# 3. Quickstart: Install SQL Server and create a database on Ubuntu
# https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu
FROM parrotsec/core:5.0.0
RUN apt-get update
RUN apt-get install --yes wget
RUN wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN wget -qO- https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list > /etc/apt/sources.list.d/mssql-server-2019.list
RUN apt-get update
RUN apt-get install --yes mssql-server
USER mssql
EXPOSE 1433
ENTRYPOINT [ "/opt/mssql/bin/sqlservr" ]
After running docker-compose up --build you can connect to the running container (in this case, from the Docker host computer) to execute SQL queries...
$ sqlcmd -S localhost,1433 -U sa -P StrongPassw0rd
1> SELECT GETDATE()
2> GO
-----------------------
2022-05-28 11:36:37.783
(1 rows affected)

Related

Using Docker to Create 3 containers: Two SQL Servers and 1 Python Image

I am trying to create 3 containers and have them run all on the same network, but I am struggling with my Python Program to establish a successful connection to a SQL server on any of these containers.
To describe my current work flow:
I have one Microsoft SQL Image Container called server_1.
I have another Microsoft SQL Image Container called server_2.
Finally, I have another container called python-connect containing a Python Image called python-file.
To show you how I created each of these containers this is what I did.
First, I created a network called databases-net as follows:
docker network create --driver bridge databases-net
Next, I proceeded to create two containers with SQL servers:
docker run -dit -d --name server_1 --network databases-net -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=StrongPassword123#' -p 1433:1433 mcr.microsoft.com/mssql/server:2019-latest
docker run -dit -d --name server_1 --network databases-net -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=StrongPassword123#' -p 1002:1433 mcr.microsoft.com/mssql/server:2019-latest
Then, I created a DockerFile as shown below for my Python Program:
FROM python:3.9.2-slim-buster
ADD dbconnTest.py .
RUN apt-get update \
&& apt-get -y install gcc \
&& apt-get -y install g++ \
&& apt-get -y install unixodbc unixodbc-dev \
&& apt-get clean
RUN pip install pandas pyodbc
CMD [ "python", "./dbconnTest.py" ]
This is the python program I am using. Currently, I am only trying to access the data inside the server_1 container:
import pandas as pd
import pyodbc
cnxn = pyodbc.connect(
'DRIVER={ODBC Driver 17 for SQL Server}' +
';SERVER=' + 'localhost, 1433' + ';UID=' + 'sa' +
';PWD=' + 'StrongPassword123#' +
';database=' + 'tempdb')
df = pd.read_sql('SELECT * FROM Addresses', cnxn)
cnxn.commit()
cnxn.close()
print(df)
To build this image and running it on a container I ran:
docker build -t python-file .
docker run -dit --name python-connect --network databases-net python-file
Once it was run, I got this error:
Traceback (most recent call last):
File "//./dbconnTest.py", line 4, in <module>
cnxn = pyodbc.connect(
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)")
It seems like the python program is not able to access any of the SQL containers I created although they are on the same network. I am quite new to Docker and after looking up many tutorials, I did not see anyone try doing this. Is it even possible to access SQL servers on containers separate from the container the python program is on? If so, how do you do so?
I've been stuck on this for a week, and would really appreciate all the help I can get on this effort. Thanks!

Bitbucket pipeline sql server database set port

I have a bitbucket pipeline that must execute django unittests. Therefore, I need a test database which should be a SQL SERVER datbase.
The pipeline looks like this:
# This is a sample build configuration for Python.
# Check our guides at https://confluence.atlassian.com/x/x4UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: python:3.7.3
pipelines:
branches:
master:
- step:
name: Setup sql
image: fabiang/sqlcmd
script:
- sqlcmd -S localhost -U sa -P $DB_PASSWORD
services:
- sqlserver
- step:
name: Run tests
caches:
- pip
script: # Modify the commands below to build your repository.
- python3 -m venv my_env
- source my_env/bin/activate
- apt-get update && apt-get install
- pip3 install -r req-dev.txt
- python3 manage.py test
- step:
name: Linter
script: # Modify the commands below to build your repository.
- pip3 install flake8
- flake8 --exclude=__init__.py migrations/
definitions:
services:
sqlserver:
image: mcr.microsoft.com/mssql/server:2017-latest
variables:
ACCEPT_EULA: Y
SA_PASSWORD: $DB_PASSWORD
And everytime when I run the pipeline I get:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2726.
I tried to do it locally but then it only work when I defined a port with the -p tag:
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=yourStrong!' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest
How can I make the pipeline work? (probably defining a port but how?)
UPDATE:
On the sqlserver tab in the result section is the following error shown:
I think the problem is when you call the script - sqlcmd -S localhost -U sa -P $DB_PASSWORD because your sqlserver is not yet completly initialized.
Try to put a sleep 10 before the command and the best is to add an error case if command fail sleep 5 and retry again.

Error: TCP Provider: Error code 0x2746. During the Sql setup in linux through terminal

I am trying to setup the ms-sql server in my linux by following the documentation
https://learn.microsoft.com/pl-pl/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-2017
The SQL server status is Active (Running).
I am getting the following error while executing the command
sqlcmd -S localhost -U SA -P '<YourPassword>'
Error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider:
Error code 0x2746. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL
Server : Client unable to establish connection.
I also tried by giving the command
sqlcmd -S 127.0.0.1 -U SA -P '<YourPassword>'
But the same error is displayed. When I tried the wrong password it also displays the same error.
[UPDATE 17.03.2020: Microsoft has released SQL Server 2019 CU3 with an Ubuntu 18.04 repository. See: https://techcommunity.microsoft.com/t5/sql-server/sql-server-2019-now-available-on-ubuntu-18-04-supported-on-sles/ba-p/1232210 . I hope this is now fully compatible without any ssl problems. Haven't tested it jet.]
Reverting to 14.0.3192.2-2 helps.
But it's possible to solve the problem also using the method indicated by Ola774, not only in case of upgrade from Ubuntu 16.04 to 18.04, but on every installation of SQL Server 2017 on Ubuntu 18.04.
It seems that Microsoft now in cu16 messed up with their own patch for the ssl-version problems applied in cu10 (https://techcommunity.microsoft.com/t5/SQL-Server/Installing-SQL-Server-2017-for-Linux-on-Ubuntu-18-04-LTS/ba-p/385983). But linking the ssl 1.0.0 libraries works.
So just do the following:
Stop SQL Server
sudo systemctl stop mssql-server
Open the editor for the service configuration by
sudo systemctl edit mssql-server
This will create an override for the original service config. It's correct that the override-file, or, more exactly "drop-in-file", is empty when used the first time.
In the editor, add the following lines to the file and save it:
[Service]
Environment="LD_LIBRARY_PATH=/opt/mssql/lib"
Create symbolic links to OpenSSL 1.0 for SQL Server to use:
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so
Start SQL Server
sudo systemctl start mssql-server
If you are having issues with the client on Debian 10 with OpenSSL1.1.1 the fix is to revert to the previously default weaker key length.
To do so:
Modify /etc/ssl/openssl.cnf config file as follows
(fyi see known issues with OpenSSL 1.1.1 in Debian 10 below):
Change the last line from CipherString = DEFAULT#SECLEVEL=2 to CipherString = DEFAULT#SECLEVEL=1
https://github.com/microsoft/msphpsql/issues/1021
https://wiki.debian.org/ContinuousIntegration/TriagingTips/openssl-1.1.1
sudo apt-get install mssql-server=14.0.3192.2-2
Reverting to this version worked for me.
My scenario was a fresh install (everything latest version) on Ubuntu Server 18.04.2 receiving the client connection error from sqlcmd:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x2746
Simply:
TCP Provider: Error code 0x2746
This is likely a problem with openssl vs. sql-server protocol/version.
Check your openssl version. Run the following command on your terminal openssl version:
$ openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
If your openssl version is not 1.0, then you may want to solve the connection problem by one of the following options:
Option 1: Workaround your openssl
sed -i -E 's/(CipherString\s*=\s*DEFAULT#SECLEVEL=)2/\11/' /etc/ssl/openssl.cnf
Yes, it is .cnf.
This command changes your SECLEVEL to 1, if you have it in your /etc/ssl/openssl.cnf file. Done.
Option 2: Downgrade openssl.
If your openssl version is 1.1, you would probably like it to be 1.0.
This method is basic: download the source code, configure and make the binary. It may take few minutes to build everything:
cd /usr/local/src/
wget https://www.openssl.org/source/old/1.0.1/openssl-1.0.1k.tar.gz
tar -xvf /usr/local/src/openssl-1.0.1k.tar.gz
cd /usr/local/src/openssl-1.0.1k
./config --prefix=/usr/local/ --openssldir=/usr/local/openssl
make
make test
make install
mv /usr/bin/openssl /usr/bin/openssl-bak
then
cp -p /usr/local/openssl/bin/openssl /usr/bin/openssl
or
cp -p /usr/local/ssl/bin/openssl /usr/bin/openssl
ll -ld /usr/bin/openssl
openssl version
Leave comments if you need insights for something special: docker image, or different system, etc.
Upgrade from Ubuntu 16.04 to 18.04 still results in some issues
A few systems may require version 1.0 of the OpenSSL libraries to connect to SQL Server. Using OpenSSL 1.0 can be done as follows:
Stop SQL Server
sudo systemctl stop mssql-server
Open the editor for the service configuration
sudo systemctl edit mssql-server
In the editor, add the following lines to the file and save it:
[Service]
Environment="LD_LIBRARY_PATH=/opt/mssql/lib"
Create symbolic links to OpenSSL 1.0 for SQL Server to use
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so
Start SQL Server
sudo systemctl start mssql-server
I hope this helps
You can either roll back to the previous version with the command sudo apt-get install mssql-server=14.0.3192.2-2 or keep the new version by following MSSQL_Ubuntu's answer.
Also disable the updates on the mssql-server package:
sudo apt-mark hold mssql-server
This will not prevent you to update it manually when you wish so.
Same problem. It's awful because im in dev now and that "great" update just killing my working time.
Update:
MS SQL version rollback helped me, but unfortunately I have to remove all my data. Thanks that it was my dev machine. All notes below tested on
ijin -> lsb_release -a
No LSB modules are available.
Distributor ID: LinuxMint
Description: Linux Mint 19 Tara
Release: 19
Codename: tara
1) I've remover MS SQL and its data
sudo rm -rf /var/opt/mssql
sudo apt-get purge mssql-server mssql-tools
sudo apt-get autoremove
sudo apt-get autoclean
2) Check available versions of MS SQL in repository
ijin -> apt-cache policy mssql-server
3) Installed custom MS SQL
sudo apt-get install mssql-server=15.0.1600.8-1 mssql-tools
4) Setup
sudo /opt/mssql/bin/mssql-conf setup
5) Mem limit, server agent
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
sudo /opt/mssql/bin/mssql-conf set memory.memorylimitmb 3072
4) Restart, status
sudo service mssql-server restart
sudo service mssql-server status
Probably there is some issues with interaction of openssl package and updated MS SQL, I can't find if it is true or not, but googled a few notes about it. So you can use
apt-cache policy openssl
sudo apt-get install openssl=<version>
openssl version
To change openssl version and try to connect.
Updated SQL Server to the version 14.0.3223.3-15 (Ubuntu 18.04.2 LTS) today and got exactly the same issue for both local and remote connections. Rolling back to the previous version (14.0.3192.2-2 in my case) worked for me:
sudo apt-get install mssql-server=14.0.3192.2-2
List versions installed on your machine:
apt-cache policy mssql-server
After trying a few solutions, I found this:
https://www.youtube.com/watch?v=mfLbCarRzpg
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0 /opt/mssql/lib/libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0 /opt/mssql/lib/libcrypto.so
sudo systemctl stop mssql-server
sudo systemctl edit mssql-server
Add these lines:
[Service]
Environment="LD_LIBRARY_PATH=/opt/mssql/lib"
Then restart the server:
sudo systemctl start mssql-server
I had the very same issue from within a docker container, I had to downgrade msodbc, mssql-tools and lib ssl:
RUN ACCEPT_EULA=Y apt-get install msodbcsql17=17.3.1.1-1 mssql-tools=17.3.0.1-1 -y
RUN wget http://security.debian.org/debian-security/pool/updates/main/o/openssl1.0/libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb \
&& dpkg -i libssl1.0.2_1.0.2s-1~deb9u1_amd64.deb
Now it works like a charm.
Just in case, older versions of ms odbc driver and tools can be found here: https://packages.microsoft.com/debian/9/prod/pool/main/m/
For openssl: http://security-cdn.debian.org/debian-security/pool/updates/main/o/openssl1.0/
I encountered the same issue with SQL Server 2019 (RTM - 15.0.2000.5) on Debian 10, both trying to connect locally with sqlcmd or remote through SSMS.
The same resolution as mentioned above was able to resolve this for me. My OpenSSL version was 1.0.2, this should be adjusted for whichever version is available.
sudo ln -s /usr/lib/x86_64-linux-gnu/libssl.so.1.0.2 /opt/mssql/lib/libssl.so
sudo ln -s /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2 /opt/mssql/lib/libcrypto.so
sudo systemctl restart mssql-server
Now both local and remote connections work OK
At this moment , only this version is working, looks like problem in openssl .
Working on Debian 9 .
Before anything be sure that you have valid backup of DB.
You need to purge mssql-server
apt-get remove --purge mssql-server
and after that check and delete /var/opt/mssql and /opt/mssql .
Next use this version 15.0.1700.37-2
apt-get install mssql-server=15.0.1700.37-2
after config you should be able to connect to mssql server 2019 at localhost or 127.0.0.1
sqlcmd -S localhost -U SA -P 'YourPassword'
After 2 days working on this problem I've finally solved it! In my case, I am using Fedora 28, so for those using RHEL, I followed this tutorial:
Installing Microsoft SQL Server on Red Hat Enterprise Linux 8 Beta
So, are you using Python 3? Apparently, you need to switch to Python 2 before installing it, using the following code (I guess in Ubuntu would work as well):
sudo alternatives --config python
Create a repository from https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo
Download it, then install it without resolving dependencies.
After that, you can run the setup for mssql-conf:
sudo /opt/mssql/bin/mssql-conf setup
And continue the Microsoft documentation tutorial from that step.
Microsoft Tutorial for installing SQL Server 2017 on RHEL
Microsoft Tutorial for installing SQL Server 2017 on Ubuntu
Note: I read in some forums that SQL Server 2019 may be causing that problem, so I recommend installing the 2017 version.
I got the same issue.
My OS is Ubuntu 18.10
sudo apt-get install mssql-server=14.0.3192.2-2
Then, in my case, I could not enter my SQL server because I got the below message
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'. Reason: Server is in script upgrade mode. Only administrator can connect at this time..
Then, I followed the ServerFault Answer
Each command took a process for a while in my case.
Update 2021, Fedora 34, Sql Server 2019.
If you still have that error you need to execute the following command:
dnf install openldap-compat
Or check what is actually happening in console by starting the mssql in a single mode:
sudo -u mssql /opt/mssql/bin/sqlservr -m
More info you can find here: https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-troubleshooting-guide?view=sql-server-ver15#connection
I don't recommend down grading openssl any more since you should be able to fix any openssl issue you have by upgrading to a new version. In my case openssl 1.1.1k worked. The easiest way to install an openssl version not in your distro is to install from source. For full details see https://wiki.openssl.org/index.php/Compilation_and_Installation
For me the following steps were sufficient but I assume you will also need build-essentials and a few other packages.
git clone git://git.openssl.org/openssl.git
cd openssl/
git checkout OpenSSL_1_1_1k
chmod +x ./config
./config
make
sudo make install
However this will not entirely solve the problem anymore. sqlcmd seems to have a DNS resolution bug that is not in older versions. That means you need the full domain name or ipaddress plus connection protocol or port number may also be required. So while before things like
sqlcmd -S 127.0.0.1
or
sqlcmd -S <server_name>
worked just fine. Now you may need something like
sqlcmd -S tcp:127.0.0.1,<port_number> or
sqlcmd -S tcp:<server_name>.<AD domain>.<domain name>,<port_number>
On my side, the problem was caused by a mounting issue. I found the solution here: https://github.com/microsoft/mssql-docker/issues/603#issuecomment-652958304
For some reason, if you map /var/opt/mssql/, and not only /var/opt/mssql/data, it fails on a Windows filesystem. There is no problem doing that on a Linux filesystem.
If your using multiple php versions, please remove all unwanted versions
sudo apt-get purge php5.*
sudo apt-get purge php5.6 #specific version
restart apache2 or nginix server
restart php sudo service php7.4-fpm restart
After 2 days of struggle in which, as suggested by various sources, I tried to:
downgrade openssl from 3 to 1
downgrade Microsoft ODBC Driver 18 to 17
update sql 2008 r2 SP3 with TLS support
change MinProtocol = TLSv1 and CipherString = DEFAULT#SECLEVEL=1
set protocol registry in windows to accept TLS1.0-TLS1.3
without any success:
error:0A000102:SSL routines::unsupported protocol]
error:0A0C0103:SSL routines::internal error]
TCP Provider: Error code 0x2746 (the last one after all the changes)
I finally found out a solution installing a lower version of ODBC Driver 17:
libmsodbcsql-17.10.so.1.1 (DIDN'T WORK) -> libmsodbcsql-17.6.so.1.1 (WORKS)
It seems that libmsodbcsql-17.10 doesn't work with sql 2008 r2 instead libmsodbcsql-17.6 does
Update 2023, SQL Server 2012, Ubuntu 22.10 with ODBC Driver 18 (installation instructions),:
/opt/microsoft/msodbcsql18/lib64/libmsodbcsql-18.2.so.1.1
from
cat /etc/apt/sources.list.d/mssql-release.list
deb [arch=amd64,armhf,arm64] https://packages.microsoft.com/ubuntu/22.10/prod kinetic main
openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)
odbcinst -q -d
[ODBC Driver 18 for SQL Server]
env | grep OPEN
OPENSSL_CONF=/home/knb/.ssh/openssl-conf-TLS1.1-mssql.cnf
# see file below
# "-C ": set "TrustServerCertificate=yes;" in the connection string.
export OPENSSL_CONF=${HOME}/.ssh/openssl-conf-TLS1.1-mssql.cnf && \
sqlcmd -S myserver -Uknb -Pxxxxx -C -q "select ##version;"
Result: Microsoft SQL Server 2012 (SP4-GDR) (KB4583465) - 11.0.7507.2 (X64)
File /home/knb/.ssh/openssl-conf-TLS1.1-mssql.cnf (For most of these, I don't know what it means)
HOME = .
oid_section = new_oids
# System default
openssl_conf = default_conf
[default_conf]
ssl_conf = ssl_sect
[ssl_sect]
system_default = system_default_sect
[system_default_sect]
CipherString = DEFAULT#SECLEVEL=0
[ new_oids ]
tsa_policy1 = 1.2.3.4.1
tsa_policy2 = 1.2.3.4.5.6
tsa_policy3 = 1.2.3.4.5.7
[ ca ]
default_ca = CA_default # The default ca section
[ CA_default ]
dir = ./demoCA # Where everything is kept
certs = $dir/certs # Where the issued certs are kept
crl_dir = $dir/crl # Where the issued crl are kept
database = $dir/index.txt # database index file.
# several certs with same subject.
new_certs_dir = $dir/newcerts # default place for new certs.
certificate = $dir/cacert.pem # The CA certificate
serial = $dir/serial # The current serial number
crlnumber = $dir/crlnumber # the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem # The current CRL
private_key = $dir/private/cakey.pem# The private key
x509_extensions = usr_cert # The extensions to add to the cert
name_opt = ca_default # Subject Name options
cert_opt = ca_default # Certificate field options
default_days = 365 # how long to certify for
default_crl_days= 30 # how long before next CRL
default_md = default # use public key default MD
preserve = no # keep passed DN ordering
policy = policy_match
[ policy_match ]
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
[ req ]
default_bits = 2048
default_keyfile = privkey.pem
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_ca # The extensions to add to the self signed cert
string_mask = utf8only
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = AU
countryName_min = 2
countryName_max = 2
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Some-State
localityName = Locality Name (eg, city)
0.organizationName = Organization Name (eg, company)
0.organizationName_default = Internet Widgits Pty Ltd
organizationalUnitName = Organizational Unit Name (eg, section)
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_max = 64
emailAddress = Email Address
emailAddress_max = 64
[ req_attributes ]
challengePassword = A challenge password
challengePassword_min = 4
challengePassword_max = 20
unstructuredName = An optional company name
[ usr_cert ]
basicConstraints=CA:FALSE
nsComment = "OpenSSL Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
[ v3_ca ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = critical,CA:true
[ crl_ext ]
authorityKeyIdentifier=keyid:always
[ proxy_cert_ext ]
basicConstraints=CA:FALSE
nsComment = "OpenSSL Generated Certificate"
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
[ tsa ]
default_tsa = tsa_config1 # the default TSA section
[ tsa_config1 ]
dir = ./demoCA # TSA root directory
serial = $dir/tsaserial # The current serial number (mandatory)
crypto_device = builtin # OpenSSL engine to use for signing
signer_cert = $dir/tsacert.pem # The TSA signing certificate
# (optional)
certs = $dir/cacert.pem # Certificate chain to include in reply
# (optional)
signer_key = $dir/private/tsakey.pem # The TSA private key (optional)
signer_digest = sha256 # Signing digest to use. (Optional)
default_policy = tsa_policy1 # Policy if request did not specify it
# (optional)
other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional)
digests = sha1, sha256, sha384, sha512 # Acceptable message digests (mandatory)
accuracy = secs:1, millisecs:500, microsecs:100 # (optional)
clock_precision_digits = 0 # number of digits after dot. (optional)
ordering = yes # Is ordering defined for timestamps?
# (optional, default: no)
tsa_name = yes # Must the TSA name be included in the reply?
# (optional, default: no)
ess_cert_id_chain = no # Must the ESS cert id chain be included?
# (optional, default: no)
ess_cert_id_alg = sha1 # algorithm to compute certificate
# identifier (optional, default: sha1)

OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'

Ubuntu 16.04.3
I'd like to install pgAdmin:
I hvae created a virtualenv with python 2.
Then install pgAdmin 4 v2.0:
pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.0/pip/pgadmin4-2.0-py2.py3-none-any.whl
It's time to run pgAdmin:
(pgadmin4) michael#michael-desktop:~/PycharmProjects/venv$ python pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
Traceback (most recent call last):
File "pgadmin4/lib/python2.7/site-packages/pgadmin4/pgAdmin4.py", line 55, in <module>
exec(open(file_quote(setupfile), 'r').read())
File "<string>", line 46, in <module>
File "/home/michael/PycharmProjects/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 23, in create_app_data_directory
_create_directory_if_not_exists(os.path.dirname(config.SQLITE_PATH))
File "/home/michael/PycharmProjects/venv/pgadmin4/lib/python2.7/site-packages/pgadmin4/pgadmin/setup/data_directory.py", line 15, in _create_directory_if_not_exists
os.mkdir(_path)
OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'
Could you give me a kick here?
If you do not want to change the permission of anything, you can always override default paths in pgAdmin4.
Create a file named config_local.py (if not already present) at your installation location ../pgadmin4/web/
File location in my case:
/usr/local/lib/python2.7/dist-packages/pgadmin4/config_local.py
and add following code in your config_local.py,
import os
DATA_DIR = os.path.realpath(os.path.expanduser(u'~/.pgadmin/'))
LOG_FILE = os.path.join(DATA_DIR, 'pgadmin4.log')
SQLITE_PATH = os.path.join(DATA_DIR, 'pgadmin4.db')
SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
STORAGE_DIR = os.path.join(DATA_DIR, 'storage')
Restart pgAdmin4 and check.
Permission error means the user 'michael' (/var/lib has drwxr-xr-x) has the permission to execute but doesn't have the permission to write on the folder (according to your comment of the folder info below).
One of the solutions you can use to be able to access freely the folder would be something like:
chown -R michael:root /path/to/the/directory
The second part of the answer, you've figured it out #Michael.
downloading pgadmin by using the command:
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.5/pip/pgadmin4-1.5-py2.py3-none-any.whl
and then execute command:
pip install pgadmin4*.whl.
create the folders manually (or add to your pgAdmin installation script, if there is one), and assign the permissions:
sudo mkdir "/var/log/pgadmin"
sudo chmod a+wrx "/var/log/pgadmin"
sudo mkdir "/var/lib/pgadmin"
sudo chmod a+wrx "/var/lib/pgadmin"
this would not assign permissions to the entire /var/log but just for the /var/log/pgadmin only.
solved issue with several steps
1. create empty folders on host vm
mkdir /private/var/lib/pgadmin
chmod 777 /private/var/lib/pgadmin
start pgadmin docker image
docker pull dpage/pgadmin4
docker run -p 80:80\
-v /private/var/lib/pgadmin:/var/lib/pgadmin \
...
you will see newly created file structure like this
/private/var/lib/pgadmin
-rw-------. 1 5050 5050 757760 Jan 13 23:11 pgadmin4.db
drwx------. 2 5050 5050 50 Jan 13 23:00 sessions
drwxr-xr-x. 3 5050 5050 31 Jan 13 23:17 storage
thus UID 5050 is our target one
4. copy your pgadmin4.db into target dir and apply proper UID [5050 in my case]
As a result application will work, user settings will be saved.
I installed pgadmin4 v2.1 on Ubuntu 16.04 and had this problem. See the last line of code. (I run this in a script file, lazy.) I also installed 2.0 this way as a test to see if it really is a fix. I did not have to use config_local.py.
cd ..
cd home/vagrant
sudo apt-get install build-essential libssl-dev libffi-dev libgmp3-dev virtualenv python-pip libpq-dev python-dev
virtualenv .pgadmin4
cd .pgadmin4
source bin/activate
wget https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v2.1/pip/pgadmin4-2.1-py2.py3-none-any.whl
pip install pgadmin4-2.1-py2.py3-none-any.whl
# For this either use your remote host panel to edit the file or:
nano lib/python2.7/site-packages/pgadmin4/config.py
# Change:
# DEFAULT_SERVER = '0.0.0.0'
# Here is the trick. Run this boot up file with sudo. This fixed it for me.
sudo python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
I had the same problem with pgAdmin4 v3.1, I just write sudo python pgAdmin4.py and it worked!.

Jenkins gcloud deployment causes ImportError

I've set up a Jenkins instance in Google Compute Engine to build and deploy an App Engine Java project following this page from Google.
I've configured Jenkins to run the following shell command only when the Maven build succeeds: gcloud --project=decent-ellipse-843 preview app deploy target/*-SNAPSHOT/
When I attempt a build, the deployment fails with the following trace:
+ gcloud --project=decent-ellipse-843 preview app deploy target/backend-api-0.0.1-SNAPSHOT/
Traceback (most recent call last):
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 183, in <module>
main()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 179, in main
_cli.Execute()
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/cli.py", line 488, in Execute
post_run_hooks=self.__post_run_hooks)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/backend.py", line 1016, in Run
result = command_instance.Run(args)
File "/usr/local/bin/../share/google/google-cloud-sdk/./lib/googlecloudsdk/calliope/exceptions.py", line 86, in TryFunc
return func(*args, **kwargs)
File "/usr/local/share/google/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 158, in Run
stage_dir = self.__MakeStagingDir(project, args, deployable)
File "/usr/local/share/google/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/deploy.py", line 268, in __MakeStagingDir
java_app_update = appcfg_java.JavaAppUpdate(deployable, args)
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg_java.py", line 146, in __init__
self.app_engine_web_xml = self._ReadAppEngineWebXml()
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg_java.py", line 205, in _ReadAppEngineWebXml
parser=app_engine_web_xml_parser.AppEngineWebXmlParser)
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/appcfg_java.py", line 217, in _ReadAndParseXml
return parser().ProcessXml(file_handle.read())
File "/usr/local/share/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/app_engine_web_xml_parser.py", line 71, in ProcessXml
xml_root = ElementTree.fromstring(xml_str)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1300, in XML
parser = XMLParser(target=TreeBuilder())
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1466, in __init__
"No module named expat; use SimpleXMLTreeBuilder instead"
ImportError: No module named expat; use SimpleXMLTreeBuilder instead
Build step 'Execute shell' marked build as failure
Finished: FAILURE
The Maven build is successful, and I can deploy the project by issuing the gcloud command manually.
Even when I run the exact same gcloud command from the same directory and under the same user (tomcat), the deployment succeeds without errors.
I have re-installed python and updated the Google Cloud SDK without any results.
The instance is running Python 2.7.3, Jenkins 1.598, JDK 7u76 and Maven 3.2.2.
I hope someone can help me out with this!
I ran into a similar issue running my jobs on the cloud-dev-python slave. The images are missing build tools that you may need in order to build and deploy properly. My solution was to connect to the docker image and install the tools manually the first time around.
# on docker host, connect to java image
CONTAINER_ID=$(docker ps | grep cloud-dev-java | awk '{print $1}');
docker exec -i -t $CONTAINER_ID bash
# on docker image, install crap to build lxml, etc
gcloud -q components update preview app && apt-get update \
&& apt-get install -y build-essential libz-dev libxml2-dev \
libxslt1-dev python-dev python-pip && apt-get autoremove
Give that a whirl and see if it helps. I'm currently stuck with the service account not authenticating even though it is set up properly...

Resources