Skip to content

Commit

Permalink
make explanation for how to call sshConfigManager
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroTochigi committed May 11, 2024
1 parent 440b6a4 commit ba452ed
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 6 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,55 @@ This command basically does the opposite of the `init.sh`
2. Delete EC2 instance
3. Delete security group on the EC2 portal
4. Delete ssh key on the AWS EC2 portal

### sshConfigManager Interface

The `sshConfigManager` interface is designed to facilitate the management of SSH configurations, providing methods to create, update, and delete SSH configuration entries. This interface streamlines the process of maintaining complex SSH config files, making it easier to manage access to multiple remote servers.

#### Create Command

**What it does:**
The `create` command generates a new entry in the SSH configuration file with detailed settings for host alias, hostname, user, port, identity file, and port forwarding options.

**How to execute:**
To add a new SSH configuration entry:

```
create "myserver" "example.com" "user" "22" "~/.ssh/id_rsa" "8888:80,9999:443"
```

This command sets up a host with alias `myserver`, connecting to `example.com` on port 22 with the specified identity file and port forwarding settings.

#### Update Command

**What it does:**
The `update` command modifies an existing SSH configuration entry for a specified host. It can change settings for any key such as `User`, `Port`, or complex keys like `RemoteForward`, where both old and new port forwarding settings need to be specified.

**How to execute:**
To change the `User` for host `myserver`:

```
update myserver User newuser
```

To update a `RemoteForward` setting:

```
update myserver RemoteForward 8888:80 8899:80
```

These commands adjust the specified configurations, replacing old values with new ones.

#### Delete Command

**What it does:**
The `delete` command removes an entire SSH configuration block for a specified host from the SSH config file, effectively discontinuing the SSH management for that host through the configuration file.

**How to execute:**
To remove the configuration for a host:

```
delete myserver
```

This command deletes all settings associated with the host `myserver`, cleaning up the SSH config file by removing unused or outdated entries.
1 change: 1 addition & 0 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ usage() {
echo "Usage: $0 credential [command]"
echo "Commands:"
echo " aws - Execute an AWS command"
echo " sshConfigManager - An interface that manages SSH configurations, allowing creation, updating, and deletion of SSH configuration entries"
exit 1
}

Expand Down
3 changes: 0 additions & 3 deletions src/utils/callUpdate.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

host="myserver"


function update(){
local host=$1
local newKey=$2
Expand Down
10 changes: 7 additions & 3 deletions src/utils/driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ function sshConfigManagerUsage() {
echo "Usage: driver <command> [options]"
echo ""
echo "Commands:"
echo " create <name> <host> <user> <port> Create a new SSH configuration"
echo " update <name> <host> <user> <port> Update an existing SSH configuration"
echo " delete <name> Delete an SSH configuration"
echo " create <host> <hostname> <user> <port> <identityfile> <remoteforward> - Generates an SSH configuration block with specified host, user, port, identity key, and port forwarding settings."
echo " <remoteforward> should be specified in the format 'local_port:remote_port', and you can include multiple mappings separated by commas to forward several ports."
echo ""
echo " update <host> <key> <new value> - Modifies an existing key-value pair in the SSH configuration for the specified host."
echo " update <host> <RemoteForward> <old value> <new value> - Updates a specific RemoteForward entry by replacing an old port mapping with a new one."
echo ""
echo " delete <host> - Removes the entire SSH configuration entry associated with the specified host."
echo ""
echo "Options:"
echo " -h, --help Show help information"
Expand Down

0 comments on commit ba452ed

Please sign in to comment.