diff --git a/.config/bash/module/Fix.sh b/.config/bash/module/Fix.sh index 0e89dea..17cf9ff 100644 --- a/.config/bash/module/Fix.sh +++ b/.config/bash/module/Fix.sh @@ -22,3 +22,42 @@ function fix_files_sftp() { function fix_gradle_lock() { cd "${HOME}/.gradle" && find -type f | grep \\.lock$ | xargs -- rm } + +# Fix Gnome's broken RDP ffs. +# Usage: fix_gnome_rdp +function fix_gnome_rdp() { + local user="${1}" + local password="${2}" + + # Check params. + if [[ "${user}" = "" ]] || [[ "${password}" = "" ]]; then + help fix_gnome_rdp + return 2 + fi + + # Unlock keyring. PROTIP: Disable password for it in password manager. + pkill -9 -f gnome-keyring-daemon + echo -n "${user}" | gnome-keyring-daemon --unlock + + # Generate keys. + cd /tmp + openssl genrsa -out rdp-tls.key 4096 + openssl req -new -key rdp-tls.key -subj "/C=US" | openssl x509 -req -days 730 -signkey rdp-tls.key -out rdp-tls.crt + mkdir -p /home/"${user}"/.local/share/gnome-remote-desktop/ + mv rdp-tls.key rdp-tls.crt /home/"${user}"/.local/share/gnome-remote-desktop/ + + # Configure RDP. + grdctl rdp set-tls-cert /home/"${user}"/.local/share/gnome-remote-desktop/rdp-tls.crt + grdctl rdp set-tls-key /home/"${user}"/.local/share/gnome-remote-desktop/rdp-tls.key + grdctl rdp set-credentials "${user}" "${password}" + grdctl rdp disable-view-only + + # Start service. + grdctl rdp enable + systemctl --user start gnome-remote-desktop.service + + # Show status. + grdctl status --show-credentials + systemctl --user status gnome-remote-desktop.service + +}