Newer
Older
% {
'participation': participation,
'flow_id': flow_id,
'session': strify_session_for_exception(session)},
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
# {{{ ssh keypair
@login_required
def generate_ssh_keypair(request):
if not request.user.is_staff:
raise PermissionDenied(_("only staff may use this tool"))
from paramiko import RSAKey
key_class = RSAKey
prv = key_class.generate(bits=2048)
import six
prv_bio = six.BytesIO()
prv.write_private_key(prv_bio)
prv_bio_read = six.BytesIO(prv_bio.getvalue())
pub = key_class.from_private_key(prv_bio_read)
pub_bio = six.BytesIO()
pub_bio.write("%s %s relate-course-key" % (pub.get_name(), pub.get_base64()))
return render(request, "course/keypair.html", {
"public_key": prv_bio.getvalue().decode(),
"private_key": pub_bio.getvalue().decode(),
})
# }}}