mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 07:37:16 -04:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d9000ab16 | ||
|
|
bdea49268d | ||
|
|
187ea39861 | ||
|
|
ee8e7fc8a5 | ||
|
|
8a4ae469fa | ||
|
|
4330617060 | ||
|
|
54397dcd13 |
@@ -47,7 +47,7 @@ Packaging for other distributions coming soon.
|
||||
# Building
|
||||
Since sshyp is written entirely in Python, it doesn't need to be compiled. It does, however, need to be packaged for installation.
|
||||
|
||||
A packaging script is included in the root directory of the repo in order to package sshyp for your distribution (currently only a generic package used for the AUR PKGBUILD is supported). To package sshyp from source, simply run:
|
||||
A packaging script is included in the root directory of the repo in order to package sshyp for your distribution. To package sshyp from source, simply run:
|
||||
|
||||
```
|
||||
git clone https://github.com/rwinkhart/sshyp.git
|
||||
@@ -55,9 +55,11 @@ cd sshyp
|
||||
./package.sh
|
||||
```
|
||||
|
||||
The packaging script has been tested on Arch Linux with dpkg as a dependency for Debian and Termux packaging.
|
||||
|
||||
The AUR version and the packages attatched to the release tags were already packaged using this script.
|
||||
|
||||
Packaging for other distributions coming soon.
|
||||
Currently, the script can create packages for Arch (PKGBUILD), Debian, Termux, and generic. Packaging for other distributions coming soon.
|
||||
|
||||
# Usage
|
||||
Upon initial installation (on both the server and client devices), be sure to run:
|
||||
|
||||
+21
-18
@@ -1,12 +1,13 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
# sshync 2022.01.10.unreleased8
|
||||
# sshync 2022.01.16.unreleased10
|
||||
|
||||
# external modules
|
||||
|
||||
from os import system, remove, walk
|
||||
from os.path import getmtime, join
|
||||
from os import system, remove, mkdir, walk
|
||||
from os.path import getmtime, join, expanduser
|
||||
from sys import exit as s_exit
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# utility functions
|
||||
@@ -15,29 +16,32 @@ def get_titles_mods(_directory, _destination, _user_data):
|
||||
_title_list, _mod_list = [], []
|
||||
# local fetching
|
||||
if _destination == 'l':
|
||||
if type(_user_data) == str:
|
||||
_user_data = str(_user_data).strip('(').strip(')').replace(' ', '').split(',')
|
||||
try:
|
||||
remove(_user_data[6] + 'sshync_database')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
if Path(expanduser('~/.config/sshync/database')).is_file():
|
||||
remove(expanduser('~/.config/sshync/database'))
|
||||
else:
|
||||
try:
|
||||
mkdir(expanduser('~/.config/sshync'), 0o700)
|
||||
except FileExistsError:
|
||||
pass
|
||||
system('touch ~/.config/sshync/database')
|
||||
for _root, _directories, _files in walk(_directory):
|
||||
for _filename in _files:
|
||||
_title_list.append(join(_root.replace(_directory, '', 1), _filename))
|
||||
_mod_list.append(int(getmtime(join(_root, _filename))))
|
||||
i = -1
|
||||
for _title in _title_list:
|
||||
open(_user_data[6] + 'sshync_database', 'a').write(str(_title) + '\n')
|
||||
open(_user_data[6] + 'sshync_database', 'a').write('^&*\n')
|
||||
open(expanduser('~/.config/sshync/database'), 'a').write(str(_title) + '\n')
|
||||
open(expanduser('~/.config/sshync/database'), 'a').write('^&*\n')
|
||||
for _mod in _mod_list:
|
||||
open(_user_data[6] + 'sshync_database', 'a').write(str(_mod) + '\n')
|
||||
open(expanduser('~/.config/sshync/database'), 'a').write(str(_mod) + '\n')
|
||||
# remote fetching
|
||||
if _destination == 'r':
|
||||
system(f"ssh -i '{_user_data[5]}' -p {_user_data[2]} {_user_data[0]}@{_user_data[1]} \"python -c 'import sshync"
|
||||
f"; sshync.get_titles_mods(\"'\"{_user_data[4]}\"'\", \"'\"l\"'\", \"'\"{_user_data}\"'\")'\"")
|
||||
system(f"sftp -P {_user_data[2]} {_user_data[0]}@{_user_data[1]}:'{_user_data[6]}sshync_database' "
|
||||
f"'{_user_data[6]}sshync_database'")
|
||||
_titles, _sep, _mods = ' '.join(open(_user_data[6] + 'sshync_database').readlines()).replace('\n', '').partition('^&*')
|
||||
system(f"sftp -P {_user_data[2]} {_user_data[0]}@{_user_data[1]}:"
|
||||
f"'{expanduser(f'/home/{_user_data[0]}/.config/sshync/database')}' "
|
||||
f"'{expanduser('~/.config/sshync/database')}'")
|
||||
_titles, _sep, _mods = ' '.join(open(expanduser('~/.config/sshync/database')).readlines()).replace('\n', '')\
|
||||
.partition('^&*')
|
||||
_title_list, _mod_list = _titles.split(' ')[:-1], _mods.split(' ')[1:]
|
||||
return _title_list, _mod_list
|
||||
|
||||
@@ -76,8 +80,7 @@ def get_profile(_profile_dir):
|
||||
_local_dir = _profile_data[3].replace('\n', '')
|
||||
_remote_dir = _profile_data[4].replace('\n', '')
|
||||
_identity = _profile_data[5].replace('\n', '')
|
||||
_data_dir = ' '.join(_profile_dir.split('/')[:-1]).replace(' ', '/') + '/'
|
||||
return _user, _ip, _port, _local_dir, _remote_dir, _identity, _data_dir
|
||||
return _user, _ip, _port, _local_dir, _remote_dir, _identity
|
||||
|
||||
|
||||
def run_profile(_profile_dir):
|
||||
|
||||
@@ -49,7 +49,7 @@ def edit_note(_shm_folder, _shm_entry):
|
||||
def tweak(): # runs configuration wizard
|
||||
# storage/config directory creation
|
||||
try:
|
||||
mkdir(f"{path.expanduser('~')}/.password-pasture", 0o700)
|
||||
mkdir(path.expanduser('~/.password-pasture'), 0o700)
|
||||
except FileExistsError:
|
||||
pass
|
||||
try:
|
||||
@@ -60,14 +60,14 @@ def tweak(): # runs configuration wizard
|
||||
# device type configuration
|
||||
_device_type = input('\nIs this installation for a client or for a server? (C/s) ')
|
||||
if _device_type.lower() == 's':
|
||||
open(f"{path.expanduser('~/.config/sshyp')}/sshyp-device", 'w').write(_device_type)
|
||||
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
||||
copy('/usr/bin/sshync.py', path.expanduser('~/'))
|
||||
print('\nMake sure the ssh service is running and properly configured.\n\nConfiguration complete!\n')
|
||||
s_exit()
|
||||
else:
|
||||
# device type configuration
|
||||
_device_type = 'c' # ensure device type flag is properly set
|
||||
open(f"{path.expanduser('~/.config/sshyp')}/sshyp-device", 'w').write(_device_type)
|
||||
open(path.expanduser('~/.config/sshyp/sshyp-device'), 'w').write(_device_type)
|
||||
|
||||
# gpg configuration
|
||||
_gpg_id = input('\nsshyp requires the use of a unique gpg key. Do you already have one that you are '
|
||||
@@ -76,14 +76,14 @@ def tweak(): # runs configuration wizard
|
||||
print('\nA unique gpg key has been generated for you.')
|
||||
system('gpg --full-generate-key')
|
||||
_gpg_id = str(input('\nPlease input the ID of your gpg key: '))
|
||||
open(f"{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
|
||||
try:
|
||||
open(f"{path.expanduser('~/.config/sshyp')}/lock", 'x').write('')
|
||||
open(path.expanduser('~/.config/sshyp/lock'), 'x').write('')
|
||||
except FileExistsError:
|
||||
pass
|
||||
system(f"gpg -r {str(_gpg_id)} -e {path.expanduser('~/.config/sshyp')}/lock")
|
||||
system(f"gpg -r {str(_gpg_id)} -e {path.expanduser('~/.config/sshyp/lock')}")
|
||||
remove(f"{path.expanduser('~/.config/sshyp')}/lock")
|
||||
|
||||
# ssh key configuration
|
||||
@@ -93,7 +93,7 @@ def tweak(): # runs configuration wizard
|
||||
if _ssh_gen.lower() != 'n':
|
||||
system('ssh-keygen -t ed25519 -f ~/.ssh/sshyp')
|
||||
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
|
||||
print('\nExample input: 10.10.10.10:9999\n')
|
||||
@@ -105,9 +105,9 @@ def tweak(): # runs configuration wizard
|
||||
print(f"\nEntry directory: /home/{_username_ssh}/.password-pasture/")
|
||||
|
||||
# sshync profile generation
|
||||
sshync.make_profile(f"{path.expanduser('~/.config/sshyp')}/sshyp.sshync",
|
||||
f"{path.expanduser('~')}/.password-pasture/", f"/home/{_username_ssh}/.password-pasture/",
|
||||
f"{path.expanduser('~')}/.ssh/sshyp", _ip, _port, _username_ssh)
|
||||
sshync.make_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'),
|
||||
path.expanduser('~/.password-pasture/'), f"/home/{_username_ssh}/.password-pasture/",
|
||||
path.expanduser('~/.ssh/sshyp'), _ip, _port, _username_ssh)
|
||||
print('\nConfiguration complete!\n')
|
||||
|
||||
|
||||
@@ -152,8 +152,8 @@ def print_info(): # prints help text based on argument
|
||||
print('/ /')
|
||||
print('/ sshyp Copyright (C) 2021 Randall Winkhart /')
|
||||
print('/ /')
|
||||
print('/ Version 2022.01.13.fr3 /')
|
||||
print('/ The Boxing Update /')
|
||||
print('/ Version 2022.01.13.fr3.1 /')
|
||||
print('/ The Boxing Update /')
|
||||
print('/ /')
|
||||
print('////////////////////////////////////////////////////////\n')
|
||||
elif argument == 'license':
|
||||
@@ -206,7 +206,7 @@ def sync(): # calls sshync to sync changes to the user's server
|
||||
# set permissions before uploading
|
||||
system('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
||||
system('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
||||
sshync.run_profile(f"{path.expanduser('~/.config/sshyp')}/sshyp.sshync")
|
||||
sshync.run_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'))
|
||||
|
||||
|
||||
def add_entry(): # adds a new entry
|
||||
@@ -381,7 +381,7 @@ def remove_data(): # deletes an entry or folder from both the client and the se
|
||||
if _entry_name.startswith('/'):
|
||||
_entry_name = _entry_name.replace('/', '', 1)
|
||||
try:
|
||||
system(f"gpg -d --output /dev/shm/sshyp.lock {path.expanduser('~/.config/sshyp')}/lock.gpg")
|
||||
system(f"gpg -d --output /dev/shm/sshyp.lock {path.expanduser('~/.config/sshyp/lock.gpg')}")
|
||||
_unlock = open('/dev/shm/sshyp.lock', 'r').readlines()
|
||||
remove('/dev/shm/sshyp.lock')
|
||||
except FileNotFoundError:
|
||||
@@ -407,10 +407,10 @@ argument = argument[:-1]
|
||||
if argument != 'tweak':
|
||||
device_type = ''
|
||||
try:
|
||||
device_type = open(f"{path.expanduser('~/.config/sshyp')}/sshyp-device").read().strip()
|
||||
device_type = open(path.expanduser('~/.config/sshyp/sshyp-device')).read().strip()
|
||||
if device_type == 'c':
|
||||
gpg_id = open(f"{path.expanduser('~/.config/sshyp')}/sshyp-gpg").read().strip()
|
||||
ssh_info = sshync.get_profile(f"{path.expanduser('~/.config/sshyp')}/sshyp.sshync")
|
||||
gpg_id = open(path.expanduser('~/.config/sshyp/sshyp-gpg')).read().strip()
|
||||
ssh_info = sshync.get_profile(path.expanduser('~/.config/sshyp/sshyp.sshync'))
|
||||
username_ssh = ssh_info[0].replace('\n', '')
|
||||
ip = ssh_info[1].replace('\n', '')
|
||||
port = ssh_info[2].replace('\n', '')
|
||||
|
||||
@@ -1,5 +1,56 @@
|
||||
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
|
||||
|
||||
sshyp 2022.01.16.fr3.1
|
||||
|
||||
The Boxing Update
|
||||
|
||||
This release is a hotfix for 2022.01.13.fr3. It fixes sshync/syncing support after the changes in the last release.
|
||||
|
||||
Changes:
|
||||
|
||||
- sshync has been updated to work with the new config directory
|
||||
- sshync now uses its own directory to store the database file
|
||||
^ this is preperation for separating sshync into its own package
|
||||
- expanduser lines in sshyp have been simplified (no user-facing impact)
|
||||
|
||||
Additions planned for minor releases:
|
||||
|
||||
** updated the manpage with more information regarding how sshyp works and how to set it up
|
||||
** ensured that it is now impossible for ghosts of entires to remain in /dev/shm
|
||||
** reduced total lines of code with small optimizations
|
||||
|
||||
&&
|
||||
|
||||
Planned for next major update (fr4, The sshyp Doing a Split Update):
|
||||
|
||||
sshyp:
|
||||
** sshyp has recieved a major visual overhaul
|
||||
^ this includes the new file list and thematic text art
|
||||
|
||||
sshync:
|
||||
** sshync has been split into a separate package and now has standalone functionality as a backup/syncing utility
|
||||
^ more details will be available in the sshync repo, once it is created
|
||||
|
||||
&&
|
||||
|
||||
Planned for next, next major update (fr5, The Farmer Shearing the sshyp Update):
|
||||
|
||||
** allow for multi-client deletion... somehow (in sshync)
|
||||
** when syncing, a check is made to see if any folders are not on all devices - if the check comes back true, it is corrected (in sshyp)
|
||||
** imporove password generator to guarantee more secure results
|
||||
** enforce permissions on the server-side
|
||||
** allow for copying entire notes (not just first line)
|
||||
** ability to pass entries as arguments for more functions
|
||||
|
||||
&&
|
||||
|
||||
Backlog:
|
||||
|
||||
** create separate gui frontend targetting mobile and desktop Linux
|
||||
** auto-completion on tab (currently unsure of best way to make this work)
|
||||
|
||||
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
|
||||
|
||||
sshyp 2022.01.13.fr3
|
||||
|
||||
The Boxing Update
|
||||
|
||||
@@ -1,19 +1,15 @@
|
||||
sshyp 2022.01.13.fr3
|
||||
sshyp 2022.01.16.fr3.1
|
||||
|
||||
The Boxing Update
|
||||
|
||||
This release adapts sshyp to be compatible with Termux and allows for packaging for various distributions in addition to Arch Linux.
|
||||
|
||||
Features:
|
||||
|
||||
- the copy function now has support for termux-clipboard-set from termux-api
|
||||
^ this allows clipboard functionality to work on Termux
|
||||
This release is a hotfix for 2022.01.13.fr3. It fixes sshync/syncing support after the changes in the last release.
|
||||
|
||||
Changes:
|
||||
|
||||
- sshyp no longer writes to/reads from /var
|
||||
^ configuration files are now stored under the user's home directory in ~/.config/sshyp
|
||||
^ this change allows for compatibility with less standard environments, such as Termux on Android
|
||||
- sshync has been updated to work with the new config directory
|
||||
- sshync now uses its own directory to store the database file
|
||||
^ this is preperation for separating sshync into its own package
|
||||
- expanduser lines in sshyp have been simplified (no user-facing impact)
|
||||
|
||||
Additions planned for minor releases:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user