Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specification for SSH-key configuration utils #142

Merged
merged 1 commit into from
Jul 21, 2017

Conversation

GowthamShanmugam
Copy link
Contributor

@GowthamShanmugam GowthamShanmugam commented Feb 20, 2017

tendrl-bug-id: #141

Signed-off-by: GowthamShanmugam gshanmug@redhat.com

@GowthamShanmugam
Copy link
Contributor Author

name: jsmith
generate_ssh_key: yes
ssh_key_bits: 2048
ssh_key_file: .ssh/id_rsa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key file should be named specifically for tendrl. Don't rely on the defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

```
* Create a new a function is utils to find ssh daemon status and port number
```
- Port number is identifiable using cat /var/run/sshd.pid, run the command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. systemctl show sshd.service. Grab the value of MainPID.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brainfunked ok i will check this

p.name() # to print service name
p.connections()
sample output:
[pconn(fd=3, family=10, type=1, laddr=('::1', 22), raddr=('::1', 54960), status='LISTEN')]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit is good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sample output:
[pconn(fd=3, family=10, type=1, laddr=('::1', 22), raddr=('::1', 54960), status='LISTEN')]
- Parse the output and return the port number
- Checkout the status in output if is listen then return result like port is open
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err? Listening on the port isn't the same as the port being open. Port being open means that the firewall configuration is proper. However, that's not in the scope of this specification, so for now, just report that the service is running and listening on a specific port.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brainfunked i understand clearly

a mandatory parameter, while the user name should be optional. User name
should default to root.
3. Check if the SSH daemon is running and get it's port number.
4. Check if the SSH incoming port is open.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not possible unless we support firewall configuration parsing. For now, we can only report on what port the sshd process listens on. Ensure that the port number and pid is returned from the method that checks for the running daemon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


== Proposed change

SSH public-key configuration have four major process:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not supposed to be an all-in-one method. Each of the following steps is supposed to be a separate utility method that always works locally on a specific node. Each of these methods must execute ansible in local mode. The entire workflow will need to be tied together with flows, which are not part of this specification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brainfunked i understand


== Implementation

* Create ansible module in commons utils to generate SSH with user. If user is present
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write down each of the methods being added and their inputs and outputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkudlej
Copy link

mkudlej commented Feb 21, 2017

@GowthamShanmugam Do I understand it right that Tendrl will create ssh key on node with Etcd and then distribute it to storage nodes? How will be key distributed to storage nodes?

@GowthamShanmugam
Copy link
Contributor Author

@mkudlej By creating new job, ssh-key is copied to particular nodes, we have to create flow and atoms for that job later. But those are out of this scope, this spec is only for utils to create and copy the ssh-keys on local node.

@GowthamShanmugam
Copy link
Contributor Author

@GowthamShanmugam
Copy link
Contributor Author

@shtripat @brainfunked @nnDarshan @r0h4n please review

@@ -0,0 +1,271 @@
= SSH configuration utilities for provisioning cluster

SSH public-key utilities are used to authenticate cluster nodes with
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow this description is not very correct I feel. This utility is more to do with helping tendrl to setup a password less ssh between the provisioning node and other cluster nodes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shtripat ok will change it

(default path is "(homedir)+/.ssh/authorized_keys")
path: "Alternate path to the authorized_keys file" (optional)
```
* Create a new a function is utils to find ssh daemon status and port number.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shtripat i will correct it


== Implementation

* Create a new utility class called GenerateSSH in commons with filename generate_ssh_utils.py.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name could be SSHUtil may be

Copy link
Contributor Author

@GowthamShanmugam GowthamShanmugam Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shtripat all the functionality is different utility so i have named utility based on its functionality, so SSHUtil not correct i feel


return status and portnumber from this
```
* There is one more utility for identifying port is open or not. It will not part of this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need separate classes for each functionality? Can there be one class with more generic name and have individual functions to do the job?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shtripat this is the requirement from @brainfunked he wants all the functionality should be a different utility

* Sanity check for flow.
* Check SSH-key is generated successfully or not
* Check SSH-key is copied successfully
* Check the user is created successfully
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be manual verification of connection to nodes using ssh which doesnt ask passwd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shtripat done

@GowthamShanmugam
Copy link
Contributor Author

@shtripat @brainfunked @r0h4n please review

}
```
* Create a new utility class called AuthorizedKey in commons with filename authorized_key_utils.py.
* AuthorizedKey should be initialized with username(default root) and pair of keys(mandatory).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are the pair of keys that you have mentioned ? can you please elaborate ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nnDarshan as we discussed i will change the sentence

* Create a new utility class called GenerateSSH in commons with filename generate_ssh_utils.py.
* GenerateSSH should take username and exec_path path as parameter to initialize object.
* Default user is root.
* Create a method called __run_module in GenerateSSH class to call ansible runner with
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This run module should return public key back right ? so that, it can be used by the user to write to authorized keys file ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nnDarshan i will return the newly generated ssh key

None

== Developer impact
None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add how a developer will be using these utils, By adding some code snippets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nnDarshan sure i will add some sample code

@GowthamShanmugam
Copy link
Contributor Author

@shtripat @brainfunked @r0h4n @nnDarshan review please

@nnDarshan
Copy link
Contributor

Looks good to me.

tendrl-bug-id: Tendrl#141

Signed-off-by: GowthamShanmugam <gshanmug@redhat.com>
@r0h4n
Copy link
Contributor

r0h4n commented Apr 28, 2017

@GowthamShanmugam please confirm all action items are implemented

@GowthamShanmugam
Copy link
Contributor Author

@r0h4n all of the actions are done, it contains three major actions

  1. generate ssh-key
  2. copy ssh key
  3. sshd status

All three are done https://github.com/Tendrl/commons/tree/develop/tendrl/commons/utils/ssh.

@r0h4n r0h4n merged commit 16a68a9 into Tendrl:spec-141-ssh-utils Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants