{"id":15050998,"url":"https://github.com/eggwite/change-ssh-port","last_synced_at":"2026-02-26T20:49:44.000Z","repository":{"id":247006547,"uuid":"824807714","full_name":"Eggwite/Change-SSH-Port","owner":"Eggwite","description":"Changes SSH port on Ubuntu, Debian, or CentOS machine with bash \"semi-automatically\". ","archived":false,"fork":false,"pushed_at":"2024-07-06T08:59:24.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T10:35:13.180Z","etag":null,"topics":["automation","bash","debian","linux","shell","ssh","ssh-server","ubuntu","ubuntu-server"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Eggwite.png","metadata":{"files":{"readme":"README.md","changelog":"change_ssh_port.sh","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-06T02:24:49.000Z","updated_at":"2025-01-03T22:48:39.000Z","dependencies_parsed_at":"2025-02-16T10:32:34.667Z","dependency_job_id":"c407a4bb-fb99-44f4-abef-74d315e9a534","html_url":"https://github.com/Eggwite/Change-SSH-Port","commit_stats":null,"previous_names":["eggwite/change-ssh-port"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eggwite%2FChange-SSH-Port","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eggwite%2FChange-SSH-Port/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eggwite%2FChange-SSH-Port/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eggwite%2FChange-SSH-Port/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eggwite","download_url":"https://codeload.github.com/Eggwite/Change-SSH-Port/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240266856,"owners_count":19774075,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bash","debian","linux","shell","ssh","ssh-server","ubuntu","ubuntu-server"],"created_at":"2024-09-24T21:30:14.107Z","updated_at":"2026-02-26T20:49:43.966Z","avatar_url":"https://github.com/Eggwite.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Change-SSH-Port\n\u003e ⚠️ **Warning:** This script has been hardly tested. Please proceed with caution.\n\nChanges SSH port on Ubuntu, Debian, or CentOS machine with bash \"semi-automatically\". Please feel free to use it at your discretion.\n\nUser must be root:\n```\nsudo -i\n```\nThen copy and run:\n```\nbash \u003c(curl -Ls https://raw.githubusercontent.com/Eggwite/Change-SSH-Port/main/change_ssh_port.sh)\n```\nOptionally, keep old firewall rules:\n```\nbash \u003c(curl -Ls https://raw.githubusercontent.com/Eggwite/Change-SSH-Port/main/change_ssh_port.sh) --old-rules\n```\n\n## Here’s a summary of what the script does:\n\n### Checks Linux Version Compatibility:\n- Ensures the script is compatible with Ubuntu, Debian, or CentOS.\n- Allows users to continue with an unsupported version if they choose.\n\n### Gets Current SSH Port:\n- Retrieves the current SSH port from the `sshd_config` file.\n- Prompts the user for the current port if it can’t be found.\n\n### Prompts for New SSH Port:\n- Asks the user to enter a new SSH port.\n- Check if the new port is available.\n\n### Creates a Backup of SSH Configuration:\n- Backs up the current SSH configuration file to `/etc/ssh/sshd_config.bak`.\n\n### Updates Firewall Rules:\n- Checks if UFW (Uncomplicated Firewall) is installed and updates rules for the new port, removing old port rules.\n- Checks if iptables is installed and updates rules for the new port, removing old port rules.\n- Optionally keeps old firewall rules if the `--old-rules` flag is provided.\n\n### Updates SSH Configuration:\n- Modifies the `sshd_config` file to use the new SSH port.\n\n### Restarts SSH Service:\n- Restart the SSH service to apply the new configuration.\n- If the restart fails, restore the original configuration and restart the service.\n\n# 💖 If you've read this far, why not give it a star? Maybe create a PR to improve my shoddy code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggwite%2Fchange-ssh-port","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feggwite%2Fchange-ssh-port","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feggwite%2Fchange-ssh-port/lists"}