atmo.keys

The code base to manage public SSH keys to be used with ATMO clusters.

atmo.keys.forms

class atmo.keys.forms.SSHKeyForm(*args, **kwargs)[source]

The form to be used when uploaded new SSH keys.

Parameters:
  • title (CharField) – Name to give to this public key
  • key (CharField) – Should start with one of the following prefixes: ssh-rsa, ssh-dss, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521
  • key_file (FileField) – This can usually be found in ~/.ssh/ on your computer.
clean_key()[source]

Checks if the submitted key data:

  • isn’t larger than 100kb
  • is a valid SSH public key (e.g. dismissing if it’s a private key)
  • does not match any of the valid key data prefixes
  • already exists in the database

atmo.keys.models

class atmo.keys.models.SSHKey(*args, **kwargs)[source]

A Django data model to store public SSH keys for logged-in users to be used in the on-demand clusters.

Parameters:
  • id (AutoField) – Id
  • created_at (DateTimeField) – Created at
  • modified_at (DateTimeField) – Modified at
  • created_by_id (ForeignKey to User) – User that created the instance.
  • title (CharField) – Name to give to this public key
  • key (TextField) – Should start with one of the following prefixes: ssh-rsa, ssh-dss, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521
  • fingerprint (CharField) – Fingerprint
exception DoesNotExist
exception MultipleObjectsReturned
VALID_PREFIXES = ['ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521']

The list of valid SSH key data prefixes, will be validated on save.

prefix

The prefix of the key data, one of the VALID_PREFIXES.

save(*args, **kwargs)[source]

Saves the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

SSHKey.VALID_PREFIXES = ['ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', 'ecdsa-sha2-nistp521']

The list of valid SSH key data prefixes, will be validated on save.

atmo.keys.utils

atmo.keys.utils.calculate_fingerprint(data)[source]

Calculate the hexadecimal fingerprint for the given key data.

Parameters:data – str - The key data to calculate the fingerprint for.
Returns:The fingerprint.
Return type:str

atmo.keys.views

atmo.keys.views.delete_key(request, id)[source]

View to delete an SSH key with the given ID.

atmo.keys.views.detail_key(request, id, raw=False)[source]

View to show the details for the SSH key with the given ID.

If the optional raw parameter is set it’ll return the raw key data.

atmo.keys.views.list_keys(request)[source]

View to list all SSH keys for the logged-in user.

atmo.keys.views.new_key(request)[source]

View to upload a new SSH key for the logged-in user.