Comments (4)
What would be the usecase for this?
To me, it sounds like a better idea to write whatever data was used as a source when loading authorized_keys to this library. If this library would allow modifying key options, then writing would definitely make sense.
from python-sshpubkeys.
The use case would be for writing code that manages the contents of authorized keys files. So, load an authorized_keys file into an instance of the class, replace one or more keys, then write the file out again.
The class wouldn't necessarily need to do file management itself, but it could have a to_str()
method or something that could be redirected to a file.
from python-sshpubkeys.
I threw together an example of what I'm talking about at mpounsett/python-sshpubkeys@34b8d7c
Usage would look something like this (using StringIO in place of a real file):
import io
from sshpubkeys import AuthorizedKeysFile
from tests.valid_keys import keys
# slice 3 keys off the top of the test keys
authorized_keys = "\n".join([x[0] for x in keys][:3])
f = io.StringIO(authorized_keys)
key_file = AuthorizedKeysFile(f, strict=False)
# modify the key list here
f.seek(0)
f.write(str(key_file))
f.seek(0)
print(f.read())
If you really wanted to get fancy, AuthorizedKeysFile
could be reimplemented as a context manager, allowing automatic writes to take place on close.
with open(keyfile, mode='w') as f:
with AuthorizedKeysFile(f, strict=False) as key_list:
key_list.append(SSHKey(...))
from python-sshpubkeys.
Any news on that? It could be quite useful for me.
from python-sshpubkeys.
Related Issues (20)
- error from Django: _SSHCipher() takes no arguments HOT 14
- Package version on PyPI is behind version on GitHub. HOT 2
- Example is wrong HOT 2
- How to get full base64 of public key? HOT 2
- UnicodeDecodeError HOT 3
- Error in SSHKey intialization in non-strict mode with DSA key non-standard bit length HOT 1
- Hash failure on python3 HOT 1
- 🔥 Vulnerable version of ecdsa HOT 1
- Version Pinning Dependencies HOT 3
- openssh security key public key formats HOT 1
- 3.2.0 Incompatible with python 2.7 HOT 3
- SyntaxError on Python 3.5, with sshpubkeys 3.2.0+ HOT 3
- Question: Support for python typing HOT 2
- ed25516? HOT 1
- Tabs and double quotes not parsed correctly in authorized_keys file HOT 1
- Issue with parse function HOT 7
- 3.3.1: pytest cannot find any units
- Generating an authorized_keys line from a SSHKey object HOT 1
- Edit Authorized Key File HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-sshpubkeys.