Skip to content

itsmejoshleach/KeyManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Password Manager:

How It Works:

  1. Encryption: The passwords are encrypted using the cryptography.Fernet symmetric encryption system. A key is generated and saved in a file (secret.key). This key is required for both encryption and decryption.
  2. Password Generation: You can generate random passwords using the generate_password function.
  3. Storing Passwords: When a password is generated or entered by the user, it's encrypted and stored in a CSV file (passwords.csv).
  4. Viewing Passwords: Stored passwords are decrypted before being shown to the user.
  5. File Security: Passwords are saved in a CSV file, and the contents are encrypted to ensure that even if the file is accessed, the passwords remain secure.

Key Operations:

  • Storing: When a password is stored, it is encrypted before being written to the CSV.
  • Loading: When the stored passwords are viewed, they are decrypted using the saved encryption key.

Example Interaction:

Password Manager
1. Generate a new password
2. Store a password
3. View stored passwords
4. Exit
Choose an option (1-4): 1
Generated Password: quick-4-flame-@dog-9-jumped

Password Manager
1. Generate a new password
2. Store a password
3. View stored passwords
4. Exit
Choose an option (1-4): 2
Enter the service name (e.g., 'Google'): Google
Enter the password to store (or leave empty to generate one): 

Password for Google stored successfully.

Password Manager
1. Generate a new password
2. Store a password
3. View stored passwords
4. Exit
Choose an option (1-4): 3

Stored Passwords:
Service: Google - Password: quick-4-flame-@dog-9-jumped

SSH Manager:

This is a Python-based SSH Manager that allows users to store, update, remove, and test SSH credentials securely. The credentials (including private/public SSH keys, usernames, and passwords) are encrypted using the cryptography library for security. This script also supports generating new SSH key pairs and uploading public keys to remote servers.

Features

  • Store SSH credentials: Save SSH username, password, private key, and public key securely in a CSV file.
  • Update SSH credentials: Update an existing SSH entry based on the service name.
  • Remove SSH credentials: Remove a specific entry from the stored SSH credentials.
  • Test SSH connection: Connect to remote servers using stored SSH credentials and test the connection.
  • Generate SSH keys: Generate a new RSA SSH key pair (private and public).
  • Upload public key: Upload the generated or existing public key to a server's authorized_keys.
  • Encrypt and decrypt data: SSH credentials are encrypted using a key generated by the cryptography library.

Requirements

  • Python 3.x
  • cryptography library
  • paramiko library
  • To install the required dependencies, run the following command: pip install cryptography paramiko

Usage

  1. Store SSH credentials

    • Select option 1 to store SSH credentials.
    • You will be prompted to enter:
      • Service name (e.g., MyServer)
      • SSH username
      • SSH password (leave empty if using a private key)
      • SSH private key (optional, if you wish to use an existing key)
      • SSH public key (optional, if you use an existing key)
      • Hostname (e.g., example.com)

    The credentials will be stored securely in a CSV file (ssh_credentials.csv), with passwords and keys encrypted.

  2. View stored SSH credentials

    • Select option 2 to view the stored SSH credentials.
    • The credentials are decrypted and displayed in the terminal.
  3. Test SSH connection

    • Select option 3 to test a connection to a server using stored SSH credentials.
    • You can connect using either the SSH username/password or a private key if available.
  4. List public key

    • Select option 4 to list the public key of a specific service.
    • You will be prompted to enter the service name, and the public key will be displayed.
  5. Upload SSH public key to server

    • Select option 5 to upload the SSH public key to a server's authorized_keys file.
    • You will be prompted to enter the service name, and the script will upload the key to the specified server and test the connection.
  6. Update SSH credentials

    • Select option 7 to update existing SSH credentials.
    • You will be prompted to enter the new credentials (username, password, private key, public key, hostname).
    • The credentials will be updated in the CSV file.
  7. Exit

    • Select option 8 to exit the program.

Key Functions

  1. generate_key()
    • Generates a new encryption key used to encrypt and decrypt the SSH credentials.
  2. save_key(key, filename="ssh_secret.key")
    • Saves the generated encryption key to a file for later use.
  3. load_key(filename="ssh_secret.key")
    • Loads the encryption key from a file.
  4. encrypt_message(message, key)
    • Encrypts a given message (e.g., SSH username, password, or key) using the encryption key.
  5. decrypt_message(encrypted_message, key)
    • Decrypts a given encrypted message using the encryption key.
  6. store_ssh_credentials(username, password, private_key, public_key, hostname, service_name, key)
    • Stores the provided SSH credentials (username, password, private key, public key, and hostname) into a CSV file, with encryption applied to sensitive information.
  7. load_ssh_credentials(key, filename="ssh_credentials.csv")
    • Loads SSH credentials from the CSV file and decrypts the information using the provided encryption key.
  8. update_creds(username, password, private_key, public_key, hostname, service_name, key, filename="ssh_credentials.csv")
    • Updates the stored SSH credentials for a specific service, replacing the old credentials with new ones.
  9. remove_ssh_credentials(service_name, key, filename="ssh_credentials.csv")
    • Removes the SSH credentials for a specific service from the CSV file.
  10. connect_ssh(username, password=None, private_key=None, hostname='localhost', port=22) - Establishes an SSH connection to a server using either username/password or private key authentication.
  11. generate_ssh_key_pair(service_name) - Generates a new RSA key pair (private and public keys) and saves them to disk.
  12. upload_ssh_key_to_server(hostname, username, password, private_key, service_name)
    • Uploads the public SSH key to the specified server's authorized_keys file, allowing SSH access without a password.

Notes

  • The script assumes that the ~/.ssh/authorized_keys file on the remote server is writable.
  • It is crucial to protect the ssh_secret.key file as it is used for encryption and decryption.
  • Always ensure the private key files are securely stored and protected.

License

This project is open source and licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages