Skip to content
gcannonincPublic
forked from chrisputnam9/pssh

About

Central Command SSH config management and server operations

Resources

Stars

1 star

Watchers

0 watching

Forks

 
 

Repository files navigation

CC-SSH - Central Command SSH Configuration Management Tool

A PHP-based SSH configuration management tool from the Central Command CLI suite.

Primary features include:

  • Ability to sync and share SSH configuration among multiple users
  • Ability to merge multiple configurations - ie. personal and work
  • Interface to manage configurations - ie. search, edit, delete, and create new host configurations
  • Ability to initialize hosts - copy individual/team keys and optionally run a custom script install

Latest Version

Download Latest Version (2.7.0):

https://raw.githubusercontent.com/gcannoninc/cc-ssh/master/dist/cc-ssh

Latest Version Hash (md5):

f832bfbe074be1c94b6772787e9c5ee7

Getting Started

Quick getting started information for the most common use case.

Install CC-SSH

  1. Make sure you have PHP, or install it if not

  2. Run this code in a download folder or temporary location:

     curl https://raw.githubusercontent.com/gcannoninc/cc-ssh/master/dist/cc-ssh > cc-ssh
     chmod +x cc-ssh
     sudo ./cc-ssh install
    
  3. Test success by running in a new terminal session:

     cc-ssh version
    

Import Existing Config

  1. Add git URL for your company's shared SSH config into ~/.central-command/ssh/config.hjson (sync:), then run:

     cc-ssh sync
    
  2. Import your current config to a new JSON file (~/.central-command/ssh/ssh_config_imported.json)

     cc-ssh import
    
  3. Merge your imported json into your synced work json file, putting overrides into a personal file ('ssh_config_personal.json' is automatically ignored by the default .gitignore, so you'll need to sync/back this up yourself as needed)

     cc-ssh merge ~/.central-command/ssh/ssh_config_imported.json ~/.central-command/ssh/ssh_config_work.json ~/.central-command/ssh/ssh_config_personal.json
    
  4. Review the personal file - conflicts will be placed here, some may require manual adjustments.

  5. Diff the work file to make sure you don't sync something you wanted to keep private! Move host entries to personal file as needed.

     cd ~/.central-command/ssh
     git difftool
    
  6. Export new JSON files to ssh config and test

     cc-ssh export
     ssh oneofyourhosts
    
  7. Sync again when ready

     cc-ssh sync
    

Updating

The script will periodically check for updates automatically and inform you when an update is available.

If an update is available, you can run the following to install the update:

sudo cc-ssh update

USAGE:

cc-ssh <method> (argument1) (argument2) ... [options]

-------------------------------------------------------------------------------------------------------------------------------------------------------
| METHOD                        | INFO                                                                                                                |
-------------------------------------------------------------------------------------------------------------------------------------------------------
| add                           | Add new SSH host - interactive, or specify options                                                                  |
| backup                        | Backup a file or files to the configured backup folder                                                              |
| clean                         | Clean json config files                                                                                             |
| clear                         | Clear the screen                                                                                                    |
| delete_host                   | Delete host                                                                                                         |
| edit_host                     | Edit host - modify config in your editor                                                                            |
| eval_file                     | Evaluate a php script file, which will have access to all internal methods via '$this'                              |
| exit                          | Exit the command prompt                                                                                             |
| export                        | Export JSON config to SSH config file                                                                               |
| help                          | Shows help/usage information.                                                                                       |
| import                        | Import SSH config data into JSON                                                                                    |
| init_host                     | Initialize host - interactive, or specify options                                                                   |
| install                       | Install a packaged PHP console tool                                                                                 |
| list                          | List all hosts                                                                                                      |
| merge                         | Merge config from one JSON file into another                                                                        |
| prompt                        | Show interactive prompt                                                                                             |
| search                        | Search for host configuration                                                                                       |
| sync                          | Sync config files based on 'sync' config/option value                                                               |
| update                        | Update an installed PHP console tool                                                                                |
| version                       | Output version information                                                                                          |
-------------------------------------------------------------------------------------------------------------------------------------------------------
To get more help for a specific method:  cc-ssh help <method>

-------------------------------------------------------------------------------------------------------------------------------------------------------
| OPTION                        | TYPE                                       | INFO                                                                   |
-------------------------------------------------------------------------------------------------------------------------------------------------------
| ----WSC--                     | (boolean)                                  | HJSON Data for config file                                             |
| --allow-root                  | (boolean)                                  | OK to run as root                                                      |
| --backup-age-limit            | (string)                                   | Age limit of backups to keep- number of days                           |
| --backup-dir                  | (string)                                   | Location to save backups                                               |
| --cache-lifetime              | (boolean)                                  | Default time to cache data in seconds                                  |
| --cli-script                  | (string)                                   | CLI script to install on hosts during init                             |
| --install-path                | (string)                                   | Install path of this tool                                              |
| --json-config-paths           | (string)                                   | Main JSON config file paths                                            |
| --json-import-path            | (string)                                   | Default JSON config import path                                        |
| --ssh-config-path             | (string)                                   | Default SSH config path                                                |
| --ssl-check                   | (boolean)                                  | Whether to check SSL certificates with curl                            |
| --stamp-lines                 | (boolean)                                  | Stamp output lines                                                     |
| --step                        | (boolean)                                  | Enable stepping points                                                 |
| --sync                        | (string)                                   | Git SSH URL to sync config data                                        |
| --timezone                    | (string)                                   | Timezone - from http://php.net/manual/en/timezones.                    |
| --update-auto                 | (int)                                      | How often to automatically check for an update (seconds, 0 to disable) |
| --update-check-hash           | (binary)                                   | Whether to check hash of download when updating                        |
| --update-last-check           | (string)                                   | Formatted timestap of last update check                                |
| --update-version-url          | (string)                                   | URL to check for latest version number info                            |
| --verbose                     | (boolean)                                  | Enable verbose output                                                  |
-------------------------------------------------------------------------------------------------------------------------------------------------------
Use no- to set boolean option to false - eg. --no-stamp-lines
=======================================================================================================================================================

Troubleshooting & Common Issues

See General CC-Con Issues

See general CC-Con issues which may apply

Error about /root/.ssh/config

During install, in some cases, ~/.central-command/ssh/config.hjson could have root's ssh config path set instead of yours.

Edit your ~/.central-command/ssh/config.hjson - search for 'root' and fix any incorrect paths to point to your actual files (typically /home/youruser/... eg. /home/youruser/.ssh/config).

Miscellaneous

Many thanks to all who've helped with suggestions, testing, issue reporting, and motivation!

About

Central Command SSH config management and server operations

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages