A script is a short file of written commands that a computer carries out for you, one after another.
This guide is for anyone who has heard that "a script runs every night" and wants to know what that means. You do not need to code. If your organisation has backups, reports or uploads that happen on their own, scripts are probably doing that work.
In short
- A script is a list of commands saved in a file, so a computer can repeat a task without a person.
- Scripts often run on a timetable, using a scheduler such as cron.
- A script that connects to other systems needs a password, key or token, so it acts as a non-human identity.
- Keep those secrets out of the script file, give each one an owner and only the access it needs.
What you will learn
- Explain the difference between a script and a larger program.
- Describe how scripts run on a timetable.
- Spot a secret typed straight into a script.
- Check who owns the scripts and keys in your organisation.
- List of commands (script)
- a file of instructions a computer follows in order.
- Command window (shell)
- a program that takes typed commands and carries them out.
- Software password (secret)
- a key, token or password a script uses to prove it may connect.
What is a script?
Think of a note of instructions you leave for a house-sitter. "Feed the cat at 7. Water the plants. Lock the back door." They follow the list in order, so you do not have to be there.
A script works the same way for a computer. A shell is a program that carries out typed commands [1]. You can save commands in a file, and that file becomes a command of its own [1]. That file is a script.
Scripts are often used to automate everyday jobs. One language's guide gives the example of renaming and rearranging lots of photo files [2]. Another, PowerShell, is often used for automating the management of systems [3].
A script and a larger program are not very different. Scripts are usually shorter and often run straight from the text, with no separate build step [2].
Where the comparison stops working: a house-sitter notices if something looks wrong. A script does exactly what it says, every time, even if the file has been changed by someone else.
Why does it matter?
Scripts save time, but many of them need keys to reach other systems. Those keys are easy to forget.
If you run a small office
What could happen: a nightly backup script holds the admin password in plain text. A copy of the file ends up on a shared drive.
Check this: ask your IT helper which scripts run on their own and what passwords they use.
If you are new to IT work
What could happen: you write a handy script using your own key. When you change jobs, the script breaks or keeps your access alive.
Check this: give each script its own account or key with only the access it needs.
If you manage a team
What could happen: nobody knows who owns an old script, so nobody notices when it is changed.
Check this: keep a simple list of scripts that run on a timetable, with an owner for each.
What does it look like?
Here is a made-up, simplified script for a nightly report. It is written in plain words, not a real language.
Example only. All values are made up.
# nightly-report script (EXAMPLE) run every night at 02:00 (1) connect to database at db.example.invalid using password FAKE-password-0000 (2) copy yesterday's sales into a report file upload report to example.invalid with key EXAMPLE-KEY-0000 (3) owner: (blank) (4)
- A scheduler starts the script at the same time each night.
- In a real file, this line would contain the database password, readable by anyone who opens the file.
- In a real file, this line would contain an upload key, typed straight into the script.
- No owner is recorded, so nobody is responsible for the keys.
Why this is risky: anyone who can read or copy the file can reuse both secrets, and nobody is watching.
The safer way: the script asks a locked secrets store for the password when it runs. It uses its own limited account and has a named owner.
How does it work?
- Write the steps. Someone saves the commands in a script file.
- Set a timetable. A scheduler starts the script at set times. On many servers this is a program called cron, which runs scheduled commands [4].
- Prove who it is. To reach a database or online service, the script shows a secret, such as a password, key or token. This makes the script a non-human identity (software that has its own access).
- Do the job. The script reads, copies or changes data with whatever access that secret allows.
- Record what happened. A good script writes a short log, without printing any secret.

One security guide notes that many organisations have secrets typed into code in plain text, and advises that secrets should not be hard-coded [5]. It also suggests changing secrets regularly, so a stolen copy only works for a short time [5].
Scripts can also be a target. In 2021, a company called Codecov reported that its upload script had been changed without permission. The changed script could send information from customers' build systems to an outside server [6]. The defensive lesson: check that scripts you download are the ones you expect, and limit what secrets they can see.
A worked example
Gideon Achterberg looks after IT for a small accountancy firm. Years ago, a former colleague wrote a script that copies client files to an online storage service every night.
Gideon is asked to check that backups are working. He opens the script and finds the storage service key typed straight into the file. The key belongs to the former colleague's own account, which has full access.
He makes a short plan. First, he creates a new account just for the backup script. It can add files to the backup folder and do nothing else.
Second, he stores the new key in the firm's secrets store. The script now fetches the key each time it runs, so the key is no longer in the file.
Third, he cancels the old key. Once that change has taken effect, any copy of the old key should no longer give access. He checks the storage service's records and sees no access he cannot explain, in the records available to him.
Finally, he adds the script to a simple list. It shows what the script does, when it runs, which key it uses and that he is the owner. He sets a reminder to review it in six months.
The backup still runs every night. Now it uses its own limited access, and someone is responsible for it.
Myths and mistakes
| What people think | What is true |
|---|---|
| A script is too small to be a security risk. | A short script can hold a powerful key. Its size says nothing about its access. |
| Using my own key in a script is fine. | Give each script its own account or key, with only the access it needs. |
| If a script runs fine, nobody needs to look at it. | Old scripts with no owner are easy to change or misuse without anyone noticing. |
| Scripts are only used by attackers. | Scripts are everyday tools for backups, reports and updates. They need the same care as any other access. |
What can I do this week?
- Ask which scripts run on their own in your organisation, and when.
- Find out which passwords, keys or tokens those scripts use.
- Move any secret typed into a script into a locked secrets store.
- Write down an owner and a review date for each script.
Checklist
- We have a list of scripts that run on a timetable.
- Each script has a named owner.
- No script file contains a password, key or token in plain text.
- Each script uses its own account or key, not a person's.
- Script keys have only the access the job needs.
- Scripts do not print secrets into logs.
- Downloaded scripts are checked before they run.
- We review old scripts and their keys at least once a year.
Common questions
Is a script the same as a program?
Nearly. A script is a kind of program. Scripts are usually short, written to automate one job, and often run straight from the text by an interpreter. Larger programs are often compiled first. The security care is the same for both.
Why is a script called a non-human identity?
Because it acts on its own and proves itself with a secret, such as a key or token. Systems let it in because of that secret, not because a person is present. That makes it an identity that needs an owner and limited access.
Where should a script keep its password?
Not in the script file. A safer way is a locked secrets store that hands the password to the script only when it runs. Some platforms also offer short-lived tokens, which expire quickly and so limit the harm if copied.
Do I need to learn PowerShell or Bash?
Not to manage the risk. You need to know which scripts run, what they do, which secrets they use and who owns them. If you want to write scripts, both are common starting points, and each has free official guides.
Where next?
Ready for the detail? Read the practitioner guide: Secrets Management Guide. It goes further into secrets stores, short-lived credentials and rotation for scripts and services.
Also useful:
- Service Accounts for Beginners
- Secrets Rotation for Beginners
- The Codecov Breach for Beginners
- Secrets in Code for Beginners
Related NHI Mgmt Group resources: Non-Human Identities for Beginners, Service Account Security Guide and Codecov Breach 2021 [6].
Key terms
- Scripting
- Writing small programs that automate tasks or join tools together.
- Shell
- The program that takes typed commands and turns them into actions.
- Cron
- A long-standing scheduler that runs commands on a server at set times.
- Script secret
- A key, token or password placed in a script so it can connect without a person.
- Service account
- An account used by software or tools rather than a person.
- Least privilege
- Giving each person, process or system only the access it needs, and no more.
Sources and further reading
- GNU Project, "What is a shell?", Bash Reference Manual. https://www.gnu.org/software/bash/manual/html_node/What-is-a-shell_003f.html (accessed 1 Dec 2026).
- Python Software Foundation, "Whetting Your Appetite", The Python Tutorial. https://docs.python.org/3/tutorial/appetite.html (accessed 1 Dec 2026).
- Microsoft Learn, "What is PowerShell?". https://learn.microsoft.com/en-us/powershell/scripting/overview (accessed 1 Dec 2026).
- Linux man-pages project, "cron(8)". https://man7.org/linux/man-pages/man8/cron.8.html (accessed 1 Dec 2026).
- OWASP, "Secrets Management Cheat Sheet", OWASP Cheat Sheet Series. https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html (accessed 1 Dec 2026).
- Codecov, "Bash Uploader Security Update", April 2021. https://about.codecov.io/security-update/ (accessed 1 Dec 2026).