best automated approach for authorized_keys and ssh config update between ssh jump host and isloated servers

114 Views Asked by At

We have isolated servers when I need to enable/disable access to the server through jump host when admin requested.

I am using openssh-server-8.9 on all machines and the client and server are using Ubuntu 22 .04 operating system.

For example, If the admin requested to enable S1 access and disable S2 and S3 access.

Currently,

  1. I am copying the public key of the jump host to the S1 server into authorized_keys and

  2. using awk/sed to remove the public key of the jump host in authorized_keys in the other two servers

  3. Update /etc/ssh/ssh_config with jump host.

Is there any best approach to automate this procedure in an effective way?

                                                                            +---------------+
                                                                            |               |
                                                                            |               |
                                                                            |               |
                                                             +-------------->               |
                                                             |              |     S1 Server |
                                                             |              |               |
                                                             |              |               |
                                                             |              +---------------+
                                                             |
+-----------------+               +------------------+       |
|                 |               |                  |       |
|                 |               |                  |       |                +--------------+
|    Client       |               |                  |       |                |              |
|                 +-------------->|    Jump Host     +-------+                |              |
|                 |               |                  |       |                |              |
|                 |               |                  |       |                |              |
+-----------------+               +------------------+       |                |  S2 Server   |
                                                             +---------------->              |
                                                             |                |              |
                                                             |                |              |
                                                             |                +--------------+
                                                             |
                                                             |
                                                             |
                                                             |                 +--------------+
                                                             |                 |              |
                                                             |                 |              |
                                                             |                 |              |
                                                             |                 |              |
                                                             |                 |   S3 Server  |
                                                             |                 |              |
                                                             +----------------->              |
                                                                               |              |
                                                                               |              |
                                                                               +--------------+
0

There are 0 best solutions below