SQL Server 2019 Standard on RHEL 8 on AWS User Guide
Overview
This guide covers launching and using the SQL Server 2019 Standard on RHEL 8 AMI from cloudimg on Amazon EC2.
SQL Server 2019 is Microsoft's relational database engine. Standard is its edition for production departmental and small-to-midsize workloads: it runs the full database engine with Microsoft's Standard edition limits on cores and buffer-pool memory (see Microsoft's SQL Server 2019 editions and features). It reports itself as Standard Edition (64-bit).
Microsoft support dates. Microsoft's mainstream support for SQL Server 2019 ended on 28 February 2025. Its extended support, with security updates, runs until 8 January 2030.
Your SQL Server licences. SQL Server 2019 Standard is licensed by Microsoft per core. No SQL Server licence is included in or sold with this listing. You need SQL Server 2019 Standard core licences with active Software Assurance (License Mobility through Software Assurance), verified with Microsoft for AWS. Licences without Software Assurance cannot be brought to AWS for SQL Server 2019. See Licensing.
Price: $0.04 per vCPU per hour (an m5.large has 2 vCPUs, so $0.08 per hour), the same rate on every instance type this listing offers. The charge covers what cloudimg adds, listed below; it includes no Microsoft licence. On top of it come your AWS infrastructure charges (EC2, EBS) and AWS's pay-as-you-go Red Hat Enterprise Linux charge, which AWS bills with the instance: the RHEL subscription is provided by AWS, and no Red Hat subscription of your own is needed or used.
What the cloudimg image adds:
- No shared or default password. The image ships SQL Server installed but not set up: there is no
masterdatabase, nosapassword and no machine key in the AMI. On your instance's first boot,mssql-firstboot.servicegenerates ansapassword on the instance and runs Microsoft's own unattended setup with it, then writes it to/root/mssql-credentials.txt(root only). No two instances share a password, a certificate or an instance identity. - Fail closed. SQL Server refuses to start until first boot has finished. If first boot cannot complete, SQL Server stays stopped and the next boot tries again.
- TLS on every connection. First boot creates the instance's own TLS key and self-signed certificate, and SQL Server forces encryption (TLS 1.2) for every client, even one that does not ask for it.
- Port 1433 closed by default. SQL Server listens on
127.0.0.1:1433only and the security group opens SSH only. You reach the database through an SSH tunnel, or open it on purpose (see Connect from other hosts). - No metadata access for the database. An nftables rule refuses every connection from SQL Server's
mssqlaccount to the EC2 instance metadata service, and the AMI requires IMDSv2. - Telemetry off (Microsoft's customer feedback program), SQL Server Agent off, and
xp_cmdshell, OLE Automation, CLR, ad hoc distributed queries and the remote admin connection all disabled. - Red Hat Enterprise Linux 8.10 built from Red Hat's official pay-as-you-go RHEL 8.10 AMI, fully patched at build time, SELinux enforcing, key-only SSH as
ec2-userwith root login disabled, anddnf-automaticapplying security updates on your instance.
What is on the image: SQL Server 2019 Standard Edition 15.0.4510.2 (CU32 with the November 2026 security update, KB5132745), mssql-tools18 (sqlcmd, bcp) and the Microsoft ODBC Driver 18 for SQL Server 18.7.1.1, all from Microsoft's official packages.microsoft.com repositories with the signing key pinned; cloud-init and the AWS Systems Manager agent.
Default user: ec2-user · Architecture: x86_64 · Recommended instance type: m5.large · Minimum: at least 4 GiB of memory (t3.medium or larger)
Licensing
SQL Server. No SQL Server licence is included in or sold with this listing. You need SQL Server 2019 Standard core licences with active Software Assurance (License Mobility through Software Assurance), verified with Microsoft for AWS. Licences without Software Assurance cannot be brought to AWS for SQL Server 2019.
- Core licences: cover the instance's vCPUs under Microsoft's per-core licensing rules.
- License Mobility through Software Assurance: the route for bringing SQL Server 2019 Standard licences to AWS. Confirm your licences with Microsoft before you launch.
Your instance accepts the Microsoft Software License Terms on first boot and sets the edition by name with MSSQL_PID=Standard; there is no product key on the image and none to enter. SQL Server licensing questions go to Microsoft or your Microsoft licensing partner.
Red Hat Enterprise Linux 8. The image is built from Red Hat's official pay-as-you-go RHEL 8.10 AMI on AWS. The RHEL subscription is provided by AWS on a pay-as-you-go basis: AWS bills its Red Hat Enterprise Linux charge with the instance, in addition to cloudimg's charge, and the instance gets its updates from Red Hat's update infrastructure (RHUI) on AWS. No Red Hat subscription of your own is needed or used, and the image does not use Red Hat Cloud Access.
What cloudimg's charge covers. The $0.04 per vCPU-hour covers what cloudimg adds: the per-instance first-boot setup with its own sa password and TLS certificate, the loopback binding with forced TLS, the metadata-service block, the fail-closed start gate and the hardened, fully patched RHEL 8.10 build. It includes no Microsoft or Red Hat licence.
Prerequisites
- An AWS account subscribed to the listing, an EC2 key pair and a VPC subnet.
- A security group that allows TCP 22 (SSH) from your admin network. Do not open 1433: SQL Server listens on the loopback address only.
- SQL Server 2019 Standard core licences with active Software Assurance (License Mobility through Software Assurance), as described under Licensing.
Instance type: m5.large is recommended. Use an instance type with at least 4 GiB of memory (t3.medium or larger). The software charge is the same rate per vCPU on every instance type this listing offers.
Step 1: Launch the instance
In the AWS Marketplace listing choose Continue to Subscribe, then Continue to Configuration, pick your Region, then Launch through EC2. Choose m5.large (recommended) or another type with at least 4 GiB of memory (t3.medium or larger), your key pair and a security group as above.
With the AWS CLI (replace the values in angle brackets):
aws ec2 run-instances --region <region> --image-id <ami-id-from-the-listing> \
--instance-type m5.large --key-name <your-key-pair> \
--security-group-ids <your-security-group> --subnet-id <your-subnet> \
--metadata-options HttpTokens=required,HttpEndpoint=enabled \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=sql-server-2019-standard}]'
First boot takes a few minutes on a new instance: Amazon EBS loads the AMI's blocks from its snapshot the first time they are read, and SQL Server's setup reads its program files. Until it finishes, systemctl is-active mssql-firstboot reports activating and /root/mssql-credentials.txt holds a placeholder. Later boots start SQL Server in seconds.
Step 2: Connect to your instance
| Version | SSH user |
|---|---|
| SQL Server 2019 Standard on RHEL 8 | ec2-user |
ssh -i <your-key.pem> ec2-user@<public-ip>
After you log in, the system shows Red Hat Enterprise Linux 8.10 with SELinux enforcing:
cat /etc/redhat-release; uname -r; getenforce
Red Hat Enterprise Linux release 8.10 (Ootpa)
4.18.0-553.186.1.el8_10.x86_64
Enforcing
Step 3: Check the service
The metadata block, the first-boot service and SQL Server all report active:
systemctl is-active cloudimg-mssql-imds-block mssql-firstboot mssql-server
active
active
active
Check what is listening. SQL Server listens on the loopback address only: 1433 is the database port, 1431 is an internal SQL Server port and 1434 is the local dedicated administrator connection (DAC), the emergency connection a sysadmin can use from the instance itself when SQL Server stops responding. Remote DAC is off. Only SSH listens on the network.
sudo ss -Htlnp | awk '{print $4, $6}' | sed 's/,pid=[0-9]*,fd=[0-9]*//g' | sort -u
0.0.0.0:22 users:(("sshd"))
[::1]:1431 users:(("sqlservr"))
[::1]:1434 users:(("sqlservr"))
127.0.0.1:1431 users:(("sqlservr"))
127.0.0.1:1433 users:(("sqlservr"))
127.0.0.1:1434 users:(("sqlservr"))
[::]:22 users:(("sshd"))
Step 4: Get your sa password
The credentials file is readable only by root. List the setting names it holds:
sudo ls -l /root/mssql-credentials.txt
sudo grep -oE '^[A-Z_0-9]+=' /root/mssql-credentials.txt
-rw-------. 1 root root 980 Nov 15 18:08 /root/mssql-credentials.txt
SA_USER=
SA_PASSWORD=
SQL_ENDPOINT=
TLS_CERT=
TLS_CERT_SHA256=
Read the whole file with sudo cat /root/mssql-credentials.txt and store the password in your password manager. It is unique to this instance.
Never pass the password to sqlcmd with -P: it would land in your shell history and the process list. sqlcmd reads it from the SQLCMDPASSWORD environment variable instead. Load it once per shell:
export SQLCMDPASSWORD="$(sudo awk -F= '/^SA_PASSWORD=/{print $2}' /root/mssql-credentials.txt)"
The blocks below repeat that line so that each one works on its own. sqlcmd is on the PATH of every login shell (/opt/mssql-tools18/bin); the blocks use the full path.
Step 5: Connect with sqlcmd
-C tells sqlcmd to trust the instance's self-signed certificate (Step 6 shows how to pin it instead).
export SQLCMDPASSWORD="$(sudo awk -F= '/^SA_PASSWORD=/{print $2}' /root/mssql-credentials.txt)"
/opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -C -Q "SET NOCOUNT ON; SELECT CAST(SERVERPROPERTY('Edition') AS nvarchar(40)) AS edition, CAST(SERVERPROPERTY('ProductVersion') AS nvarchar(20)) AS version, CAST(SERVERPROPERTY('ProductUpdateLevel') AS nvarchar(10)) AS cu, CAST(SERVERPROPERTY('ProductUpdateReference') AS nvarchar(12)) AS kb, CAST(SERVERPROPERTY('EngineEdition') AS int) AS engine_edition"
edition version cu kb engine_edition
---------------------------------------- -------------------- ---------- ------------ --------------
Standard Edition (64-bit) 15.0.4510.2 CU32 KB5132745 2
engine_edition 2 is Standard edition.
Step 6: Confirm the connection is encrypted
SQL Server forces encryption, so even a client that asks only for optional encryption (-No) gets an encrypted session:
export SQLCMDPASSWORD="$(sudo awk -F= '/^SA_PASSWORD=/{print $2}' /root/mssql-credentials.txt)"
/opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -C -No -Q "SET NOCOUNT ON; SELECT encrypt_option, protocol_type, auth_scheme FROM sys.dm_exec_connections WHERE session_id = @@SPID"
encrypt_option protocol_type auth_scheme
---------------------------------------- ---------------------------------------- ----------------------------------------
TRUE TSQL SQL
The certificate is this instance's own, named after its hostname:
openssl x509 -in /etc/ssl/mssql/mssql.pem -noout -subject -enddate -ext subjectAltName -fingerprint -sha256
subject=CN = ip-172-31-92-180.ec2.internal
notAfter=Nov 12 18:07:22 2036 GMT
X509v3 Subject Alternative Name:
DNS:ip-172-31-92-180.ec2.internal, DNS:ip-172-31-92-180, DNS:localhost, IP Address:127.0.0.1
SHA256 Fingerprint=8D:DE:AE:BF:E7:34:D0:64:E1:C0:A5:E3:D4:F0:CD:F8:98:BC:A2:ED:E6:C6:64:E7:C9:D7:1C:0E:48:D4:2D:51
The same fingerprint is in /root/mssql-credentials.txt as TLS_CERT_SHA256. To verify the server instead of trusting it blindly, copy /etc/ssl/mssql/mssql.pem (the public certificate, never mssql.key) to your client and add it to the client's trusted certificates, or pin the fingerprint in tools that support it. Because the certificate names localhost and 127.0.0.1, verification also passes through the SSH tunnel in Step 8.
Step 7: Run SQL
Create a database, write a row, read it back and drop the database:
export SQLCMDPASSWORD="$(sudo awk -F= '/^SA_PASSWORD=/{print $2}' /root/mssql-credentials.txt)"
/opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -C -W -Q "SET NOCOUNT ON; CREATE DATABASE demo; EXEC('USE demo; CREATE TABLE dbo.notes (id INT IDENTITY PRIMARY KEY, body NVARCHAR(200) NOT NULL); INSERT INTO dbo.notes (body) VALUES (N''hello from SQL Server 2019 Standard'');'); SELECT id, body FROM demo.dbo.notes; DROP DATABASE demo;"
id body
-- ----
1 hello from SQL Server 2019 Standard
For an application, create its own login and database instead of using sa. Run this in an interactive sqlcmd session (/opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -C), choosing your own strong password:
CREATE DATABASE appdb;
GO
CREATE LOGIN appuser WITH PASSWORD = N'<a-strong-password>', CHECK_POLICY = ON;
GO
USE appdb;
CREATE USER appuser FOR LOGIN appuser;
ALTER ROLE db_owner ADD MEMBER appuser;
GO
Step 8: Connect from other hosts
The safest way to use SQL Server Management Studio, Azure Data Studio, VS Code or an application on your workstation is an SSH tunnel. Port 1433 stays closed to the network:
ssh -i <your-key.pem> -N -L 1433:127.0.0.1:1433 ec2-user@<public-ip>
Then connect your client to 127.0.0.1,1433 with SQL Server authentication as sa, encryption Mandatory (or Strict), and either trust the server certificate or install mssql.pem as a trusted certificate (Step 6).
To open port 1433 deliberately, for applications on other hosts in your VPC, change the listen address and restart SQL Server, then allow TCP 1433 in the security group from those hosts' CIDRs only, never from 0.0.0.0/0. The image runs no host firewall, so the security group is what limits who can connect:
sudo /opt/mssql/bin/mssql-conf unset network.ipaddress
sudo systemctl restart mssql-server
aws ec2 authorize-security-group-ingress --group-id <your-security-group> --protocol tcp --port 1433 --cidr <app-subnet-cidr>
Encryption stays forced. The certificate names the instance's hostname, localhost and 127.0.0.1; clients connecting by another name need to trust the certificate or use a certificate you issue for that name (mssql-conf set network.tlscert and network.tlskey, then restart). To close it again, run sudo /opt/mssql/bin/mssql-conf set network.ipaddress 127.0.0.1, restart SQL Server and remove the security group rule.
Security details
Hardening settings, as SQL Server reports them:
export SQLCMDPASSWORD="$(sudo awk -F= '/^SA_PASSWORD=/{print $2}' /root/mssql-credentials.txt)"
/opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -C -W -Q "SET NOCOUNT ON; SELECT name, CAST(value_in_use AS int) AS value_in_use FROM sys.configurations WHERE name IN (N'xp_cmdshell', N'clr enabled', N'Ole Automation Procedures', N'Ad Hoc Distributed Queries', N'remote admin connections') ORDER BY name"
name value_in_use
---- ------------
Ad Hoc Distributed Queries 0
clr enabled 0
Ole Automation Procedures 0
remote admin connections 0
xp_cmdshell 0
Network, TLS and telemetry settings:
sudo /opt/mssql/bin/mssql-conf get network
sudo /opt/mssql/bin/mssql-conf get telemetry customerfeedback
ipaddress : 127.0.0.1
tcpport : 1433
tlscert : /etc/ssl/mssql/mssql.pem
tlskey : /etc/ssl/mssql/mssql.key
tlsprotocols : 1.2
forceencryption : 1
customerfeedback : false
The metadata block is an nftables table that rejects every packet from the mssql account (SQL Server runs as that account) to the EC2 metadata addresses; nft prints the account by its numeric uid (id -u mssql). As mssql the metadata service does not answer (000); as root it does (200):
sudo nft list table inet cloudimg_mssql_imds
sudo runuser -u mssql -- curl -s -m 5 -o /dev/null -w 'as mssql: %{http_code}\n' -X PUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' http://169.254.169.254/latest/api/token
sudo curl -s -m 5 -o /dev/null -w 'as root: %{http_code}\n' -X PUT -H 'X-aws-ec2-metadata-token-ttl-seconds: 60' http://169.254.169.254/latest/api/token
table inet cloudimg_mssql_imds {
chain output {
type filter hook output priority filter; policy accept;
meta skuid 993 ip daddr { 168.63.129.16, 169.254.169.254 } counter packets 4 bytes 240 reject with icmp port-unreachable
meta skuid 993 ip6 daddr fd00:ec2::254 counter packets 0 bytes 0 reject with icmpv6 port-unreachable
}
}
as mssql: 000
as root: 200
- First boot (
/usr/local/sbin/mssql-firstboot.sh) creates the TLS key and certificate, generates thesapassword into a root-only file in memory, and runsmssql-conf -n setup accept-eulawithMSSQL_PID=Standard, passing the password in the environment (never on a command line). It then checks the edition and build, that a wrongsapassword is refused, that the connection is encrypted, that port 1433 serves the instance's certificate and listens on localhost only, and that themssqlaccount cannot reach the metadata service, before it writes the credentials file. Its log isjournalctl -u mssql-firstboot. - Start gate.
mssql-server.servicehas a drop-in,/etc/systemd/system/mssql-server.service.d/50-cloudimg.conf, that requirescloudimg-mssql-imds-block.serviceand refuses to start unless the metadata block is loaded and first boot has written/var/lib/cloudimg/mssql-ready. - Dedicated administrator connection (DAC). Standard edition opens the DAC, SQL Server's emergency sysadmin connection, on
127.0.0.1:1434and[::1]:1434only.remote admin connectionsis 0, so the DAC cannot be reached from another host, and the security group never opens 1434. To use it, connect from the instance itself withsqlcmd -S 127.0.0.1,1434 -U sa -C(one DAC session at a time). - Operating system. SELinux is enforcing; SSH accepts keys only and refuses root logins (
/etc/ssh/sshd_config.d/00-cloudimg.conf, included first fromsshd_config); the root account is locked with no password set. - Data and logs live under
/var/opt/mssql(data/,log/errorlog); configuration is/var/opt/mssql/mssql.conf.
The DAC listens locally only. The errorlog records it, and connections to ports 1433 and 1434 on the instance's private address are refused:
sudo grep -a 'Dedicated admin' /var/opt/mssql/log/errorlog | cut -c24-
for p in 1433 1434; do timeout 3 bash -c "exec 3<>/dev/tcp/$(hostname -I | awk '{print $1}')/$p" 2>/dev/null && echo "$p open" || echo "$p refused"; done
Server Dedicated admin connection support was established for listening locally on port 1434.
1433 refused
1434 refused
Maintenance
Updates. The image was fully patched when it was built, and dnf-automatic installs Red Hat security updates every day. To check by hand:
sudo dnf -q check-update >/dev/null; echo "pending updates: $?"
sudo dnf -q updateinfo list --security | wc -l
pending updates: 0
0
0 and 0 mean nothing is pending (dnf check-update exits 100 when updates are available). SQL Server cumulative and security updates come from Microsoft's repository, which the image already trusts; install them when you are ready:
sudo dnf -y upgrade mssql-server mssql-tools18 msodbcsql18
Backups. Back up to a local file, then copy it off the instance (for example to Amazon S3):
sqlcmd -S 127.0.0.1 -U sa -C -Q "BACKUP DATABASE appdb TO DISK = N'/var/opt/mssql/data/appdb.bak' WITH CHECKSUM, COMPRESSION"
Standard edition supports backup compression and encrypted backups. Take EBS snapshots of the volume as a second layer.
Change the sa password. Connect as sa and run ALTER LOGIN sa WITH PASSWORD = N'<new-password>';, then update /root/mssql-credentials.txt if you keep it.
Memory. By default SQL Server on Linux uses up to 80% of the instance's memory, and Standard edition caps the buffer pool at Microsoft's Standard edition limit. To leave more for other software, set a limit and restart, for example sudo /opt/mssql/bin/mssql-conf set memory.memorylimitmb 4096 then sudo systemctl restart mssql-server.
SQL Server Agent. Standard edition includes SQL Server Agent for scheduled jobs. It ships turned off; turn it on when you need it:
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
sudo systemctl restart mssql-server
Licences when you resize. Standard is licensed per core. If you move to an instance type with more vCPUs, make sure your SQL Server core licences cover it; SQL Server uses only the cores its edition allows (the errorlog line using N logical processors based on SQL Server licensing shows the count).
Support
cloudimg's support team is on hand 24 hours a day by email for this image, with a guaranteed response within 24 hours: launch and first login, the sa password and credentials file, SSH tunnels and client connections, TLS and the instance certificate, SQL Server configuration, SELinux and dnf on RHEL 8, updates and troubleshooting. SQL Server licensing questions go to Microsoft or your Microsoft licensing partner.
Contact: support@cloudimg.co.uk or www.cloudimg.co.uk/support
Microsoft and SQL Server are trademarks of the Microsoft group of companies. Red Hat and Red Hat Enterprise Linux are trademarks of Red Hat, Inc. cloudimg is not affiliated with or endorsed by Microsoft or Red Hat.