Created
March 22, 2018 20:25
-
-
Save dotdoom/bc2e3cf8cfe2f1a10eb7a0e48851ec85 to your computer and use it in GitHub Desktop.
Forgot PIN for Linux Remote Desktop, but still have SSH access? Here's a solution. Remember to backup all config files!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Portions Copyright Chromium Project. | |
import base64 | |
import hashlib | |
import hmac | |
import json | |
import os | |
import sys | |
if len(sys.argv) != 2: | |
print 'Usage: {} <pin>'.format(sys.argv[0]) | |
sys.exit(1) | |
config_dir = os.path.expanduser('~/.config/chrome-remote-desktop') | |
for config_file in os.listdir(config_dir): | |
if config_file.endswith('.json'): | |
config_file = os.path.join(config_dir, config_file) | |
config = json.load(open(config_file)) | |
config['host_secret_hash'] = 'hmac:' + base64.b64encode( | |
hmac.new(str(config['host_id']), sys.argv[1], | |
hashlib.sha256).digest()) | |
json.dump(config, open(config_file, 'w')) | |
print 'Written', config_file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment