(I'm talking about atama-hyprland - I referenced it a couple of times there, but it's not actually a real module yet because my Hyprland config needs a serious cleanup before it's publishable)
40 lines
No EOL
3.3 KiB
Bash
40 lines
No EOL
3.3 KiB
Bash
#!/bin/bash
|
|
|
|
# extra precautions until run_hooks_as_user: true is fixed
|
|
if [ -n "$SUDO_USER" ]; then
|
|
USER="$SUDO_USER";
|
|
HOME="$(realpath "~$USER")";
|
|
HOME=${HOME%"/~$USER"};
|
|
fi
|
|
|
|
mkdir -p "$HOME/.ssh/dcli-waydroid-ssh"
|
|
|
|
if [ ! -f "$HOME/.ssh/dcli-waydroid-ssh/ssh_host_rsa_key" ]; then
|
|
ssh-keygen -f "$HOME/.ssh/dcli-waydroid-ssh/ssh_host_rsa_key" -N '' -t rsa
|
|
fi
|
|
|
|
#No need to make sure that „our key” is added - login should be password-based anyway (at least it was in my testing - it seems that passwords are the default on Arch). The file simply needs to exist and have SOMETHING in there, so that the config won't be upset.
|
|
if [ ! -f "$HOME/.ssh/authorized_keys" ]; then
|
|
if [ ! -f "$HOME/.ssh/dcli-waydroid-ssh/ssh_user_key.pub" ]; then
|
|
ssh-keygen -f "$HOME/.ssh/dcli-waydroid-ssh/ssh_user_key" -N ''
|
|
fi
|
|
cat "$HOME/.ssh/dcli-waydroid-ssh/ssh_user_key.pub" >> "$HOME/.ssh/authorized_keys"
|
|
fi
|
|
|
|
cat << EOF > "$HOME/.ssh/dcli-waydroid-ssh/sshd_config"
|
|
Port 2222
|
|
HostKey $HOME/.ssh/dcli-waydroid-ssh/ssh_host_rsa_key
|
|
AuthorizedKeysFile $HOME/.ssh/authorized_keys
|
|
ChallengeResponseAuthentication no
|
|
UsePAM yes
|
|
PermitUserEnvironment yes
|
|
PidFile $HOME/.ssh/dcli-waydroid-ssh/sshd.pid
|
|
EOF
|
|
|
|
echo "Extra things to note:
|
|
* Launch your server with \`/usr/bin/sshd -f \"$HOME/.ssh/dcli-waydroid-ssh/sshd_config\"\` (if using the atama-hyprland DCli module - it's added to auto-start).
|
|
* The server launches in the background - don't be afraid that the command simply exits. To stop it, simply \`killall sshd\`.
|
|
* Connect to it with \`ssh -p 2222 \"$USER@localhost\`\". It should simply ask for your password, but in the event it fails with a public-key error, please provide a private key param (\`ssh -p 2222 -i \"<path to key>.pub\" \"$USER@localhost\"\`).
|
|
* If a private key is needed (see above), it should should correspond to the public key in your \"$HOME/.ssh/authorized_keys\" file (if you don't remember creating one, chances are it got autogenerated for you by this hook (in that case, the file will be \"$HOME/.ssh/dcli-waydroid-ssh/ssh_user_key\"), or if that didn't happen, but you still don't know which key could it be (eg. there was one provided by your OS) - simply remove \"$HOME/.ssh/authorized_keys\" and run this hook again to have it auto-generate).
|
|
* Connecting instructions above apply to Linux's OpenSSH package - of course, when connecting from Waydroid (which is the intention of this module, after all), you'll need to translate that command syntax to GUI actions in whatever-SSH-client-for-Android-you-choose yourself.
|
|
* If you want be able to launch GUI apps on the Linux side from the Waydroid side, as well as have general QoL improvements (eg. have your Flatpaks included on the path, or the ability to control user-level SystemD services), it's recommended that you run \`env > \"$HOME/.ssh/environment\"\` on every login from a process that already has access to all your environment variables (either a terminal running on the Linux side (not from a remote SSH session) or - better yet (to not pollute the env with terminal-specific things that may not apply to your SSH app, as well as to avoid running it over and over manually) - have it happen on your WM startup, which is already the case in atama-hyprland) on every login (not just once because envars can AND WILL change after re-log)." |