How to Use ShellGPT in Kali Linux: Install, Examples and Safe Practice

ShellGPT is an AI-powered command-line tool that integrates OpenAI’s GPT model into Kali Linux, assisting cybersecurity professionals and ethical hackers in automating security tasks. It enhances efficiency by generating commands, automating reconnaissance, and providing insights into penetration testing tools like Nmap, Metasploit, and SQLMap. This blog covers: Understanding ShellGPT and its role in ethical hacking Installation and configuration in Kali Linux Automating reconnaissance, exploitation, and reporting Practical use cases for CEH v13 preparation Advanced customization and real-world applications By integrating ShellGPT into cybersecurity workflows, ethical hackers can improve their efficiency, accuracy, and automation in penetration testing, making it an essential tool for CEH v13 aspirants and security professionals.

Mar 28, 2025 - 11:47
Updated: 9 days ago
109.6k
How to Use ShellGPT in Kali Linux: Install, Examples and Safe Practice

Quick answer: ShellGPT is a Python command-line tool, run as sgpt, that sends your prompt to a large language model API and prints the answer, including suggested shell commands. On Kali, install it with pipx install shell-gpt, supply an API key, and always read a command before you run it. Never send client data to it.

Key takeaways

  • ShellGPT (sgpt) is a thin client for an LLM API. It needs an API key and an internet connection.
  • On current Kali, use pipx to avoid Python's externally-managed-environment error.
  • Treat every generated command as untrusted until you understand it.
  • Do not paste target data, credentials or client details into a third-party API.

What ShellGPT is

ShellGPT is an open-source command-line tool, installed as the sgpt command, that sends your prompt to a language model API and shows the reply in the terminal. It can also suggest a shell command and, if you confirm, run it. It does not understand your system. It writes plausible text, and the quality depends on your question and the model behind it. The project is on GitHub, where the current install steps and options are documented; check there because they change.

Where it helps in a learning lab

  • Reminding you of command syntax you rarely use.
  • Explaining what an unfamiliar command or flag does.
  • Drafting small shell or Python snippets that you then read and test.

It is a note-taker's helper, not a testing tool. It does not perform scans or exploits by itself, and it does not replace knowing Nmap, Wireshark or Linux fundamentals.

Install on Kali

Recent Kali releases follow Python's rule that system-wide pip install is blocked ("externally-managed-environment"). Use pipx, which gives each tool its own environment.

sudo apt update
sudo apt install pipx
pipx ensurepath
pipx install shell-gpt
sgpt --version

Open a new terminal after pipx ensurepath so your PATH updates. If sgpt is not found, that is the usual cause. The Kali documentation covers package management basics.

Set an API key

ShellGPT needs an API key from the provider it talks to. Create one in your provider account, then supply it when ShellGPT asks on first run, or set it as an environment variable as the project README describes. Keep the key out of shell history and public repositories. API usage may cost money, so check your provider's pricing and set a spending limit.

Basic use

sgpt "explain what the nmap -sV flag does"
sgpt --shell "list the 10 largest files in this directory"
sgpt --code "python function that reads a text file and counts words"

In shell mode, ShellGPT shows the command and asks whether to execute, describe or abort. Choose describe if you do not understand it. Flags differ by version, so run sgpt --help.

Safe practice

  1. Read before you run. A wrong or destructive command, such as a bad rm or a scan of the wrong range, runs with your privileges.
  2. Stay in scope. In any testing exercise, only act on targets you are authorised to test, such as your own lab VMs. A suggestion from a chatbot is not authorisation.
  3. Do not leak data. Prompts go to a third party. Never include client names, IP ranges, credentials, internal hostnames or captured data.
  4. Verify against documentation. Confirm flags in the man page or official docs. The Nmap reference guide is the authority for Nmap.
  5. Do not rely on it in exams. Proctored certification exams generally do not allow outside tools. Check the rules for your exam.

Where this fits with CEH

CEH v13 is branded "CEH v13 AI" because the course includes AI-assisted security topics. Tools like ShellGPT illustrate one such use: speeding up routine command-line work. The exam and the CEH Practical test your own understanding, so use ShellGPT to learn commands, then practise without it. See the EC-Council CEH page for the current exam details.

Troubleshooting

ProblemLikely cause and fix
sgpt: command not foundRun pipx ensurepath and open a new terminal
externally-managed-environment errorYou used pip; use pipx instead
Authentication errorKey missing, wrong or expired; check the provider account
Rate or quota errorUsage limit reached; check billing and limits

Next steps

Read the overview of why hackers use ShellGPT in Kali and the guide to command-line shells in Kali. For structured training, see the CEH v13 AI course.

Related reading

Frequently Asked Questions

ShellGPT is an open-source command-line client, run as sgpt, that sends prompts to a large language model API and prints answers or suggested shell commands. It needs an API key and an internet connection.

Install pipx with sudo apt install pipx, run pipx ensurepath, then pipx install shell-gpt and open a new terminal. Pipx avoids Python's externally-managed-environment error on current Kali.

Only after you read and understand them. Generated commands can be wrong or destructive and run with your privileges. Use the describe option, check the man page and only test authorised targets.

Not with a hosted API, because prompts are sent over the internet. The project documents options for local models, so check its current README if you need offline use.

No. Prompts go to a third-party service. Never include client names, IP ranges, credentials, internal hostnames or captured data. Use it for general syntax questions only.

Proctored certification exams generally restrict outside tools and AI assistants. Check the exact rules for your exam before you sit it. Use ShellGPT to learn, then practise without it.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Vaishnavi

Vaishnavi is a skilled tech professional at the Ethical Hacking Training Institute in Pune, responsible for managing and optimizing the technical infrastructure that supports advanced cybersecurity education. With deep expertise in network security, backend operations, and system performance, she ensures that practical labs, online modules, and assessments run smoothly and securely. Her behind-the-scenes contributions play a vital role in delivering a seamless and secure learning experience for aspiring ethical hackers.