mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-06 09:07:13 -04:00
Various visual consistency updates
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ def get_profile(_profile_dir):
|
|||||||
try:
|
try:
|
||||||
_profile_data = open(_profile_dir).readlines()
|
_profile_data = open(_profile_dir).readlines()
|
||||||
except (FileNotFoundError, IndexError):
|
except (FileNotFoundError, IndexError):
|
||||||
print('\nEither the profile does not exist, or it is corrupted.\n')
|
print('\n\u001b[38;5;9merror: the profile does not exist or is corrupted.\u001b[0m\n')
|
||||||
_profile_data = None
|
_profile_data = None
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
# extract data from profile
|
# extract data from profile
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ def pass_gen():
|
|||||||
if __special < __min_special:
|
if __special < __min_special:
|
||||||
__gen = _pass_gen_function(__complexity, __length)
|
__gen = _pass_gen_function(__complexity, __length)
|
||||||
return __gen
|
return __gen
|
||||||
_length = int(input('How many characters should be in the password? '))
|
_length = int(input('password length: '))
|
||||||
if _length > 840:
|
if _length > 840:
|
||||||
_length = 840
|
_length = 840
|
||||||
print('\n\u001b[38;5;9mpassword length has been limited to the maximum of 840 characters\u001b[0m\n')
|
print('\n\u001b[38;5;9mpassword length has been limited to the maximum of 840 characters\u001b[0m\n')
|
||||||
_complexity = str(input('Should the password be simple (for compatibility) or complex (for security)? (s/C) '))
|
_complexity = str(input('password complexity - simple (for compatibility) or complex (for security)? (s/C) '))
|
||||||
_gen = _pass_gen_function(_complexity, _length)
|
_gen = _pass_gen_function(_complexity, _length)
|
||||||
return _gen
|
return _gen
|
||||||
|
|
||||||
@@ -153,11 +153,11 @@ def tweak(): # runs configuration wizard
|
|||||||
else:
|
else:
|
||||||
system(f"ln -s /dev/shm {path.expanduser('~/.config/sshyp/tmp')}")
|
system(f"ln -s /dev/shm {path.expanduser('~/.config/sshyp/tmp')}")
|
||||||
# device type configuration
|
# device type configuration
|
||||||
_device_type = input('\nIs this installation for a client or for a server? (C/s) ')
|
_device_type = input('\nclient or server installation? (C/s) ')
|
||||||
if _device_type.lower() == 's':
|
if _device_type.lower() == 's':
|
||||||
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
||||||
Path(path.expanduser('~/.config/sshyp/deleted')).mkdir(0o700, parents=True, exist_ok=True)
|
Path(path.expanduser('~/.config/sshyp/deleted')).mkdir(0o700, parents=True, exist_ok=True)
|
||||||
print('\nMake sure the ssh service is running and properly configured.\n\nConfiguration complete!\n')
|
print('\nmake sure the ssh service is running and properly configured\n\nconfiguration complete\n')
|
||||||
s_exit(0)
|
s_exit(0)
|
||||||
else:
|
else:
|
||||||
# device type configuration
|
# device type configuration
|
||||||
@@ -165,12 +165,12 @@ def tweak(): # runs configuration wizard
|
|||||||
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
||||||
|
|
||||||
# gpg configuration
|
# gpg configuration
|
||||||
_gpg_id = input('\nsshyp requires the use of a unique gpg key. Do you already have one that you are '
|
_gpg_id = input('\nsshyp requires the use of a unique gpg key - do you already have one that you are '
|
||||||
'willing to use? (y/N)')
|
'willing to use? (y/N)')
|
||||||
if _gpg_id.lower() != 'y':
|
if _gpg_id.lower() != 'y':
|
||||||
print('\nA unique gpg key has been generated for you.')
|
print('\na unique gpg key has been generated for you.')
|
||||||
system(f"{gpg} --full-generate-key")
|
system(f"{gpg} --full-generate-key")
|
||||||
_gpg_id = str(input('\nPlease input the ID of your gpg key: '))
|
_gpg_id = str(input('\nplease input the id of your gpg key: '))
|
||||||
open(path.expanduser('~/.config/sshyp/sshyp-gpg'), 'w').write(_gpg_id + '\n')
|
open(path.expanduser('~/.config/sshyp/sshyp-gpg'), 'w').write(_gpg_id + '\n')
|
||||||
|
|
||||||
# lock file generation
|
# lock file generation
|
||||||
@@ -179,24 +179,23 @@ def tweak(): # runs configuration wizard
|
|||||||
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
||||||
|
|
||||||
# ssh key configuration
|
# ssh key configuration
|
||||||
_ssh_gen = (input('\nMake sure the ssh service on the remote server is running and properly configured.'
|
_ssh_gen = (input('\nmake sure the ssh service on the remote server is running and properly configured'
|
||||||
'\n\nSync support requires a unique ssh key. Would you like to have this automatically '
|
'\n\nsync support requires a unique ssh key - would you like to have this automatically '
|
||||||
'generated? (Y/n) '))
|
'generated? (Y/n) '))
|
||||||
if _ssh_gen.lower() != 'n':
|
if _ssh_gen.lower() != 'n':
|
||||||
if uname()[0] == 'Haiku':
|
if uname()[0] == 'Haiku':
|
||||||
Path(f"{path.expanduser('~')}/.ssh").mkdir(0o700, exist_ok=True)
|
Path(f"{path.expanduser('~')}/.ssh").mkdir(0o700, exist_ok=True)
|
||||||
system('ssh-keygen -t ed25519 -f ~/.ssh/sshyp')
|
system('ssh-keygen -t ed25519 -f ~/.ssh/sshyp')
|
||||||
else:
|
else:
|
||||||
print(f"\nEnsure that the key file you are using is located at {path.expanduser('~/.ssh/sshyp')}")
|
print(f"\nensure that the key file you are using is located at {path.expanduser('~/.ssh/sshyp')}")
|
||||||
|
|
||||||
# ssh ip+port configuration
|
# ssh ip+port configuration
|
||||||
print('\nExample input: 10.10.10.10:9999\n')
|
_ip_port = str(input('\nexample input: 10.10.10.10:9999\n\nip and ssh port of the remote server: '))
|
||||||
_ip_port = str(input('What is the IP and ssh port of the remote server? '))
|
|
||||||
_ip, _sep, _port = _ip_port.partition(':')
|
_ip, _sep, _port = _ip_port.partition(':')
|
||||||
|
|
||||||
# ssh user configuration
|
# ssh user configuration
|
||||||
_username_ssh = str(input('\nWhat is the username of the remote server? '))
|
_username_ssh = str(input('\nusername of the remote server: '))
|
||||||
print(f"\nEntry directory: /home/{_username_ssh}/.password-pasture/")
|
print(f"\nentry directory: /home/{_username_ssh}/.password-pasture/")
|
||||||
|
|
||||||
# sshync profile generation
|
# sshync profile generation
|
||||||
sshync.make_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'),
|
sshync.make_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'),
|
||||||
@@ -206,14 +205,14 @@ def tweak(): # runs configuration wizard
|
|||||||
# device name configuration
|
# device name configuration
|
||||||
for _name in listdir(path.expanduser('~/.config/sshyp/devices')): # remove existing device name
|
for _name in listdir(path.expanduser('~/.config/sshyp/devices')): # remove existing device name
|
||||||
remove(f"{path.expanduser('~/.config/sshyp/devices/')}{_name}")
|
remove(f"{path.expanduser('~/.config/sshyp/devices/')}{_name}")
|
||||||
print('\nIMPORTANT: This name MUST be unique amongst your client devices. '
|
print('\n\u001b[4;1mimportant:\u001b[0m This name \u001b[4;1mmust\u001b[0m be unique amongst your client '
|
||||||
'\nThis is used to keep track of which devices have up-to-date databases.\n')
|
'devices\n\nthis is used to keep track of which devices have up-to-date databases.\n')
|
||||||
_client_device_name = str(input('What would you like to name this device? '))
|
_client_device_name = str(input('device name: '))
|
||||||
open(f"{path.expanduser('~/.config/sshyp/devices/')}{_client_device_name}", 'w')
|
open(f"{path.expanduser('~/.config/sshyp/devices/')}{_client_device_name}", 'w')
|
||||||
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {_port} {_username_ssh}@{_ip} "
|
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {_port} {_username_ssh}@{_ip} "
|
||||||
f"\"touch '/home/{_username_ssh}/.config/sshyp/devices/{_client_device_name}'\"")
|
f"\"touch '/home/{_username_ssh}/.config/sshyp/devices/{_client_device_name}'\"")
|
||||||
|
|
||||||
print('\nConfiguration complete!\n')
|
print('\nconfiguration complete\n')
|
||||||
|
|
||||||
|
|
||||||
def print_info(): # prints help text based on argument
|
def print_info(): # prints help text based on argument
|
||||||
@@ -309,7 +308,7 @@ def print_info(): # prints help text based on argument
|
|||||||
def no_arg(): # displays a list of entries and gives an option to select one for viewing
|
def no_arg(): # displays a list of entries and gives an option to select one for viewing
|
||||||
print("\nFor a list of usable commands, run 'sshyp help'.")
|
print("\nFor a list of usable commands, run 'sshyp help'.")
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
_read_entry = str(input('Entry to read: '))
|
_read_entry = str(input('entry to read: '))
|
||||||
if not Path(f"{directory}{_read_entry}.gpg").exists():
|
if not Path(f"{directory}{_read_entry}.gpg").exists():
|
||||||
print(f"\n\u001b[38;5;9merror: entry ({_read_entry}) does not exist\u001b[0m\n")
|
print(f"\n\u001b[38;5;9merror: entry ({_read_entry}) does not exist\u001b[0m\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
@@ -330,7 +329,7 @@ def read_shortcut(): # shortcut to quickly read an entry
|
|||||||
|
|
||||||
|
|
||||||
def sync(): # calls sshync to sync changes to the user's server
|
def sync(): # calls sshync to sync changes to the user's server
|
||||||
print('\nSyncing entries with the server device...\n')
|
print('\nsyncing entries with the server device...\n')
|
||||||
# check for deletions
|
# check for deletions
|
||||||
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
||||||
f"'import sshypRemote; sshypRemote.deletion_check(\"'\"{client_device_name}\"'\")'\"")
|
f"'import sshypRemote; sshypRemote.deletion_check(\"'\"{client_device_name}\"'\")'\"")
|
||||||
@@ -350,7 +349,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
rmtree(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}")
|
rmtree(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
if silent_sync != 1:
|
if silent_sync != 1:
|
||||||
print('Folder does not exist locally.')
|
print('folder does not exist locally.')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if silent_sync != 1:
|
if silent_sync != 1:
|
||||||
@@ -358,7 +357,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}.gpg")
|
remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}.gpg")
|
||||||
except (FileNotFoundError, IsADirectoryError):
|
except (FileNotFoundError, IsADirectoryError):
|
||||||
if silent_sync != 1:
|
if silent_sync != 1:
|
||||||
print('File does not exist locally.')
|
print('file does not exist locally.')
|
||||||
# check for new folders
|
# check for new folders
|
||||||
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
||||||
f"'import sshypRemote; sshypRemote.folder_check()'\"")
|
f"'import sshypRemote; sshypRemote.folder_check()'\"")
|
||||||
@@ -386,7 +385,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
def add_entry(): # adds a new entry
|
def add_entry(): # adds a new entry
|
||||||
_shm_folder, _shm_entry = None, None # sets base-line values to avoid errors
|
_shm_folder, _shm_entry = None, None # sets base-line values to avoid errors
|
||||||
if argument == 'add note' or argument == 'add -n' or argument == 'add password' or argument == 'add -p':
|
if argument == 'add note' or argument == 'add -n' or argument == 'add password' or argument == 'add -p':
|
||||||
_entry_name = str(input('\nName of entry: '))
|
_entry_name = str(input('\nname of entry: '))
|
||||||
else:
|
else:
|
||||||
_entry_name = argument.split(' ')
|
_entry_name = argument.split(' ')
|
||||||
del _entry_name[:2]
|
del _entry_name[:2]
|
||||||
@@ -399,10 +398,10 @@ def add_entry(): # adds a new entry
|
|||||||
_notes = open(f"{tmp_dir}{_shm_folder}/{_shm_entry}-n", 'r').read()
|
_notes = open(f"{tmp_dir}{_shm_folder}/{_shm_entry}-n", 'r').read()
|
||||||
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines('\n\n\n' + _notes)
|
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines('\n\n\n' + _notes)
|
||||||
elif argument.startswith('add password') or argument.startswith('add -p'):
|
elif argument.startswith('add password') or argument.startswith('add -p'):
|
||||||
_username = str(input('Username: '))
|
_username = str(input('username: '))
|
||||||
_password = str(input('Password: '))
|
_password = str(input('password: '))
|
||||||
_url = str(input('URL: '))
|
_url = str(input('url: '))
|
||||||
_add_note = input('Add a note to this entry? (y/N) ')
|
_add_note = input('add a note to this entry? (y/N) ')
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_shm_folder, _shm_entry = shm_gen()
|
||||||
if _add_note.lower() == 'y':
|
if _add_note.lower() == 'y':
|
||||||
system(f"nano {tmp_dir}{_shm_folder}/{_shm_entry}-n")
|
system(f"nano {tmp_dir}{_shm_folder}/{_shm_entry}-n")
|
||||||
@@ -411,14 +410,14 @@ def add_entry(): # adds a new entry
|
|||||||
_notes = ''
|
_notes = ''
|
||||||
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_password + '\n' + _username + '\n' + _url +
|
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_password + '\n' + _username + '\n' + _url +
|
||||||
'\n' + _notes)
|
'\n' + _notes)
|
||||||
print('\nEntry preview:')
|
print('\n\u001b[1mentry preview:\u001b[0m')
|
||||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||||
encrypt(_shm_folder, _shm_entry, _entry_name)
|
encrypt(_shm_folder, _shm_entry, _entry_name)
|
||||||
|
|
||||||
|
|
||||||
def add_folder(): # creates a new folder
|
def add_folder(): # creates a new folder
|
||||||
if argument == 'add folder' or argument == 'add -f':
|
if argument == 'add folder' or argument == 'add -f':
|
||||||
_folder_name = str(input('Name of new folder: '))
|
_folder_name = str(input('name of new folder: '))
|
||||||
else:
|
else:
|
||||||
_folder_name = argument.split(' ')
|
_folder_name = argument.split(' ')
|
||||||
del _folder_name[:2]
|
del _folder_name[:2]
|
||||||
@@ -433,7 +432,7 @@ def add_folder(): # creates a new folder
|
|||||||
def rename(): # renames an entry or folder
|
def rename(): # renames an entry or folder
|
||||||
if argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
if argument == 'edit rename' or argument == 'edit relocate' or argument == 'edit -r':
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
_entry_name = str(input('What would you like to rename/relocate? '))
|
_entry_name = str(input('entry/folder to rename/relocate: '))
|
||||||
else:
|
else:
|
||||||
_entry_name = argument.split(' ')
|
_entry_name = argument.split(' ')
|
||||||
del _entry_name[:2]
|
del _entry_name[:2]
|
||||||
@@ -441,7 +440,7 @@ def rename(): # renames an entry or folder
|
|||||||
if not Path(f"{directory}{_entry_name}.gpg").exists():
|
if not Path(f"{directory}{_entry_name}.gpg").exists():
|
||||||
print(f"\n\u001b[38;5;9merror: entry ({_entry_name}) does not exist\u001b[0m\n")
|
print(f"\n\u001b[38;5;9merror: entry ({_entry_name}) does not exist\u001b[0m\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
_new_name = str(input('New Name: '))
|
_new_name = str(input('new name: '))
|
||||||
if _entry_name.startswith('/'):
|
if _entry_name.startswith('/'):
|
||||||
_entry_name = _entry_name.replace('/', '', 1)
|
_entry_name = _entry_name.replace('/', '', 1)
|
||||||
if _entry_name.endswith('/'):
|
if _entry_name.endswith('/'):
|
||||||
@@ -459,7 +458,7 @@ def edit(): # edits the contents of an entry
|
|||||||
if argument == 'edit username' or argument == 'edit -u' or argument == 'edit password' or argument == 'edit -p' or \
|
if argument == 'edit username' or argument == 'edit -u' or argument == 'edit password' or argument == 'edit -p' or \
|
||||||
argument == 'edit url' or argument == 'edit -l' or argument == 'edit note' or argument == 'edit -n':
|
argument == 'edit url' or argument == 'edit -l' or argument == 'edit note' or argument == 'edit -n':
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
_entry_name = str(input('What file would you like to edit? '))
|
_entry_name = str(input('entry to edit: '))
|
||||||
else:
|
else:
|
||||||
_entry_name = argument.split(' ')
|
_entry_name = argument.split(' ')
|
||||||
del _entry_name[:2]
|
del _entry_name[:2]
|
||||||
@@ -480,18 +479,18 @@ def edit(): # edits the contents of an entry
|
|||||||
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_lines)
|
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_lines)
|
||||||
|
|
||||||
if argument.startswith('edit username') or argument.startswith('edit -u'):
|
if argument.startswith('edit username') or argument.startswith('edit -u'):
|
||||||
_detail = str(input('New Username: '))
|
_detail = str(input('new username: '))
|
||||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 1, _detail + '\n')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 1, _detail + '\n')
|
||||||
elif argument.startswith('edit password') or argument.startswith('edit -p'):
|
elif argument.startswith('edit password') or argument.startswith('edit -p'):
|
||||||
_detail = str(input('New Password: '))
|
_detail = str(input('new password: '))
|
||||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 0, _detail + '\n')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 0, _detail + '\n')
|
||||||
elif argument.startswith('edit url') or argument.startswith('edit -l'):
|
elif argument.startswith('edit url') or argument.startswith('edit -l'):
|
||||||
_detail = str(input('New URL: '))
|
_detail = str(input('new url: '))
|
||||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 2, _detail + '\n')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 2, _detail + '\n')
|
||||||
elif argument.startswith('edit note') or argument.startswith('edit -n'):
|
elif argument.startswith('edit note') or argument.startswith('edit -n'):
|
||||||
edit_note(_shm_folder, _shm_entry)
|
edit_note(_shm_folder, _shm_entry)
|
||||||
remove(f"{directory}{_entry_name}.gpg")
|
remove(f"{directory}{_entry_name}.gpg")
|
||||||
print('\nEntry preview:')
|
print('\n\u001b[1mentry preview:\u001b[0m')
|
||||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||||
encrypt(_shm_folder, _shm_entry, _entry_name)
|
encrypt(_shm_folder, _shm_entry, _entry_name)
|
||||||
|
|
||||||
@@ -503,7 +502,7 @@ def gen(): # generates a password for a new or an existing entry
|
|||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
else:
|
else:
|
||||||
print()
|
print()
|
||||||
_entry_name = str(input('Name of service: '))
|
_entry_name = str(input('name of service: '))
|
||||||
elif argument.startswith('gen update') or argument.startswith('gen -u'):
|
elif argument.startswith('gen update') or argument.startswith('gen -u'):
|
||||||
_entry_name = argument.split(' ')
|
_entry_name = argument.split(' ')
|
||||||
del _entry_name[:2]
|
del _entry_name[:2]
|
||||||
@@ -519,11 +518,11 @@ def gen(): # generates a password for a new or an existing entry
|
|||||||
print(f"\n\u001b[38;5;9merror: entry ({_entry_name}) does not exist\u001b[0m\n")
|
print(f"\n\u001b[38;5;9merror: entry ({_entry_name}) does not exist\u001b[0m\n")
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
else:
|
else:
|
||||||
_username = str(input('Username: '))
|
_username = str(input('username: '))
|
||||||
_password = pass_gen()
|
_password = pass_gen()
|
||||||
if not argument.startswith('gen update') and not argument.startswith('gen -u'):
|
if not argument.startswith('gen update') and not argument.startswith('gen -u'):
|
||||||
_url = str(input('URL: '))
|
_url = str(input('url: '))
|
||||||
_add_note = input('Add a note to this entry? (y/N) ')
|
_add_note = input('add a note to this entry? (y/N) ')
|
||||||
_shm_folder, _shm_entry = shm_gen()
|
_shm_folder, _shm_entry = shm_gen()
|
||||||
if _add_note.lower() == 'y':
|
if _add_note.lower() == 'y':
|
||||||
system(f"nano {tmp_dir}{_shm_folder}/{_shm_entry}-n")
|
system(f"nano {tmp_dir}{_shm_folder}/{_shm_entry}-n")
|
||||||
@@ -532,7 +531,7 @@ def gen(): # generates a password for a new or an existing entry
|
|||||||
_notes = ''
|
_notes = ''
|
||||||
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_password + '\n' + _username + '\n' + _url + '\n'
|
open(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 'w').writelines(_password + '\n' + _username + '\n' + _url + '\n'
|
||||||
+ _notes)
|
+ _notes)
|
||||||
print('\nEntry preview:')
|
print('\n\u001b[1mentry preview:\u001b[0m')
|
||||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||||
encrypt(_shm_folder, _shm_entry, _entry_name)
|
encrypt(_shm_folder, _shm_entry, _entry_name)
|
||||||
else:
|
else:
|
||||||
@@ -540,7 +539,7 @@ def gen(): # generates a password for a new or an existing entry
|
|||||||
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
system(f"{gpg} -qd --output {tmp_dir}{_shm_folder}/{_shm_entry} '{directory}{_entry_name}.gpg'")
|
||||||
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 0, _password + '\n')
|
replace_line(f"{tmp_dir}{_shm_folder}/{_shm_entry}", 0, _password + '\n')
|
||||||
remove(f"{directory}{_entry_name}.gpg")
|
remove(f"{directory}{_entry_name}.gpg")
|
||||||
print('\nEntry preview:')
|
print('\n\u001b[1mentry preview:\u001b[0m')
|
||||||
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
entry_reader(f"{tmp_dir}{_shm_folder}/{_shm_entry}")
|
||||||
encrypt(_shm_folder, _shm_entry, _entry_name)
|
encrypt(_shm_folder, _shm_entry, _entry_name)
|
||||||
|
|
||||||
@@ -549,7 +548,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard
|
|||||||
if argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' \
|
if argument == 'copy username' or argument == 'copy -u' or argument == 'copy password' or argument == 'copy -p' \
|
||||||
or argument == 'copy url' or argument == 'copy -l' or argument == 'copy note' or argument == 'copy -n':
|
or argument == 'copy url' or argument == 'copy -l' or argument == 'copy note' or argument == 'copy -n':
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
_read_entry = str(input('Entry to copy: '))
|
_read_entry = str(input('entry to copy: '))
|
||||||
else:
|
else:
|
||||||
_read_entry = argument.split(' ')
|
_read_entry = argument.split(' ')
|
||||||
del _read_entry[:2]
|
del _read_entry[:2]
|
||||||
@@ -606,7 +605,7 @@ def copy_data(): # copies a specified field of an entry to the clipboard
|
|||||||
def remove_data(): # deletes an entry from the server and flags it for local deletion on sync
|
def remove_data(): # deletes an entry from the server and flags it for local deletion on sync
|
||||||
if argument == 'shear' or argument == '-rm':
|
if argument == 'shear' or argument == '-rm':
|
||||||
entry_list_gen()
|
entry_list_gen()
|
||||||
_entry_name = str(input('What would you like to delete? '))
|
_entry_name = str(input('entry/folder to shear: '))
|
||||||
else:
|
else:
|
||||||
_entry_name = argument.split(' ')
|
_entry_name = argument.split(' ')
|
||||||
del _entry_name[:1]
|
del _entry_name[:1]
|
||||||
@@ -618,7 +617,7 @@ def remove_data(): # deletes an entry from the server and flags it for local de
|
|||||||
_unlock = open(f"{tmp_dir}sshyp.lock", 'r').readlines()
|
_unlock = open(f"{tmp_dir}sshyp.lock", 'r').readlines()
|
||||||
remove(f"{tmp_dir}sshyp.lock")
|
remove(f"{tmp_dir}sshyp.lock")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print('\nAccess denied.\n')
|
print('\n\u001b[38;5;9m-access denied-\u001b[0m\n')
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
||||||
f"'import sshypRemote; sshypRemote.delete(\"'\"{_entry_name}\"'\")'\"")
|
f"'import sshypRemote; sshypRemote.delete(\"'\"{_entry_name}\"'\")'\"")
|
||||||
|
|||||||
+2
-2
@@ -14,12 +14,12 @@ def delete(_file_path):
|
|||||||
try:
|
try:
|
||||||
rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}")
|
rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print('Folder does not exist remotely.')
|
print('folder does not exist remotely')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
|
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print('File does not exist remotely.')
|
print('file does not exist remotely')
|
||||||
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
|
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
|
||||||
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}^&*{_device_name}", 'w')
|
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}^&*{_device_name}", 'w')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user