r/SQLServer • u/dgillz • Dec 05 '25
Question SQL Server sa password recovery
I need to recover the sa password. Not reset but recover.
Are there any commercially available tools to do this? Any other way to do this?
11
Upvotes
•
u/AutoModerator Dec 05 '25
After your question has been solved /u/dgillz, please reply to the helpful user's comment with the phrase "Solution verified".
This will not only award a point to the contributor for their assistance but also update the post's flair to "Solved".
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
15
u/Grogg2000 Dec 05 '25
if sa password is hard coded. Would "copy-dbalogin -login 'sa' -force" help?
Now... as everybody else wonders.. why the f did the developer go for 'sa'? 😂
10
u/RetiredMormon Dec 05 '25
If you are moving between servers can’t you just copy the login over using dbatools?
4
u/PassAdvanced487 Dec 05 '25
Try to use sp_revlogin
2
u/alexjp8 Dec 05 '25
Restore the master database in the new server
2
u/Nefka_at_work Dec 05 '25
You can get the hashed password of sa login from the old server and use it to create the login on the new server with hashed password.
3
u/artifex78 Dec 05 '25
I'm not aware of any way to recover a lost sa password. You'll have to reset it, which is easy but requires a short downtime.
5
u/BigHandLittleSlap Dec 05 '25
Install sp_help_revlogin.
Run it. It'll spit out the list of user accounts (including sa) and their password hashes in a convenient "CREATE LOGIN" script format.
With that you can either:
a) Transfer the account to a new target server, which apparently is the plan anyway.
b) Crack the password. I'm betting the password is weak, given the rest of your story.
The hashes of weak passwords can be reversed into the original plain text surprisingly quickly using something like hashcat.
Use a machine with a decent NVIDIA GPU for hashcat if you have one available. You can try something like 20 billion hashes per second with an RTX 3090, for example.
That's fast enough to reverse all 8-character alphanumeric passwords in about 3 hours. More symbols or longer passwords would take longer, but it's worth a shot. You can also grind through lists of top 10 million common passwords, variants of the company name, etc...
1
u/BadSnapshot Dec 05 '25
Not from inside SQL Server, no. The hashes are not reversible
You could try a dictionary attack, I am sure there are scripts for that.
Why can't you reset it?
2
u/ussv0y4g3r Dec 05 '25
As long as new server is running same SQL version, all you have to do is make sure new SQL server is installed on same partition, then just ccopy all databases (including master) from old server to new one. Then fix the sysservers table so new server name is set as local.
1
u/paultoc Dec 05 '25
Seems like this article is discussing the similar issue and suggesting a solution with revlogin script
https://www.sqlservercentral.com/forums/topic/transfering-the-sa-password-from-one-server-to-another
1
u/zeocrash Dec 05 '25
Aren't passwords like this generally unrecoverable for security reasons.
My understanding is that SQL server passwords are stored as a salted hash, which is a 1 way operation.
0
u/jkg007 Dec 05 '25 edited Dec 05 '25
Try this:
https://stackoverflow.com/questions/21349937/how-to-reset-sql-server-sa-password
Edit: I have also had to use the SQLCMD method described in this article
https://www.goengineer.com/blog/solidworks-pdm-how-to-reset-the-sql-sa-user-password#:~:text=Open%20SSMS%20by%20searching%20for,boxes%20if%20they're%20checked.
0
u/Idenwen Dec 05 '25
look if you application stores the SQL connect string somewhere in plain, there you have UID=SA;PWD=<password>
0
u/Chirag_S8 Dec 05 '25
The actual sa password cannot be recovered — it is stored in a one-way hashed form by the SQL Server and no commercial tool can be used to decrypt it.
What can be done is to reset it, but you will need local administrative rights on the server to do that. Normally, the procedure is to run SQL Server in single-user mode and then create a new sysadmin login or change the sa password from there.
If you lack local admin access, you are essentially out of luck — there is no legitimate software that can extract the password from the system tables of SQL Server. The only supported way is resetting with the right privileges.
2
u/[deleted] Dec 05 '25
[removed] — view removed comment