remote_assistance
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| remote_assistance [2023/09/22 20:03] – steve | remote_assistance [2025/10/02 23:27] (current) – steve | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ==== Remote Assistance ==== | ==== Remote Assistance ==== | ||
| - | First, to assist someone, you need to have your server set up to provide assistance; have a dns entry pointing to your server, have ports forwarded to that server, and be running an ssh server on that port. And, that port shouldn' | + | First, to assist someone, you need to have your server set up to provide assistance; have a dns entry pointing to your server, have ports forwarded to that server |
| Start by creating a user that can't log in; | Start by creating a user that can't log in; | ||
| < | < | ||
| - | # This is done as root. | + | # This is done as root on the server that will be providing assistance. |
| useradd --comment " | useradd --comment " | ||
| Line 16: | Line 16: | ||
| cat ~/ | cat ~/ | ||
| - | ssh -i ~/ | + | ssh -i ~/ |
| # You should get logged back in, with a new shell | # You should get logged back in, with a new shell | ||
| Line 27: | Line 27: | ||
| # Below is appended to the end of your sshd_config to prevent the user from logging in. | # Below is appended to the end of your sshd_config to prevent the user from logging in. | ||
| cat << EOT >> / | cat << EOT >> / | ||
| - | Match User secretuser | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | Match User secretuser@cyli.org | + | Match User secretuser,secretuser@cyli.org |
| | | ||
| | | ||
| Line 41: | Line 34: | ||
| | | ||
| | | ||
| + | | ||
| | | ||
| EOT | EOT | ||
| Line 47: | Line 41: | ||
| systemctl restart sshd.service | systemctl restart sshd.service | ||
| - | # You should repeat the test above to verify that it works as expected. | + | # You should repeat the test above to verify that it works as expected, meaning you can't log in. |
| Line 60: | Line 54: | ||
| # This script sets up most everything you should need for a Remote Assistance | # This script sets up most everything you should need for a Remote Assistance | ||
| + | # A function to create log files; | ||
| mkdir -p ~/.Logs | mkdir -p ~/.Logs | ||
| Log() | Log() | ||
| Line 65: | Line 60: | ||
| tee -a ~/ | tee -a ~/ | ||
| } | } | ||
| + | |||
| + | # First, and foremost, we need to have OpenSSH Server installed; | ||
| + | sudo apt-get install openssh-server | Log | ||
| # Set up the keys | # Set up the keys | ||
| - | mkdir -p ~/.ssh | + | mkdir -m 0700 -p ~/.ssh |
| cp / | cp / | ||
| - | chmod 0600 .ssh/ | + | chmod 0600 ~/.ssh/ |
| cp / | cp / | ||
| - | chmod 0644 .ssh/ | + | chmod 0644 ~/.ssh/ |
| - | cat .ssh/ | + | cat ~/.ssh/ |
| - | chmod 0644 .ssh/ | + | chmod 0644 ~/.ssh/ |
| mkdir ~/bin | mkdir ~/bin | ||
| cd ~/bin | cd ~/bin | ||
| + | |||
| # The construction below creates a file (adminaccess.service) and then cats | # The construction below creates a file (adminaccess.service) and then cats | ||
| # everything to it until it matches the string ' | # everything to it until it matches the string ' | ||
| - | # out the leading tab that was added to make this easier to read. | + | # out the leading tab that was added to make this easier to read. The " |
| - | cat << | + | # returns the user you're logged in as, and this is the user that will get assistance. |
| + | cat <<- EndOfText > adminaccess.service | ||
| [Unit] | [Unit] | ||
| Description=Permit admin access from secretuser@cyli.org | Description=Permit admin access from secretuser@cyli.org | ||
| Line 106: | Line 106: | ||
| WantedBy=multi-user.target | WantedBy=multi-user.target | ||
| EndOfText | EndOfText | ||
| + | |||
| chmod a+x adminaccess.service | chmod a+x adminaccess.service | ||
| sudo cp adminaccess.service / | sudo cp adminaccess.service / | ||
| echo "Added adminaccess.service (1)" | Log | echo "Added adminaccess.service (1)" | Log | ||
| - | cat <<- ' | + | # Script below is a helper to enable the service, the "'" |
| + | # The variables remain as variable instead of expanding. | ||
| + | cat <<- ' | ||
| # | # | ||
| # This script connects to cyli.org for assistance, opening | # This script connects to cyli.org for assistance, opening | ||
| Line 126: | Line 129: | ||
| esac | esac | ||
| EndOfText | EndOfText | ||
| - | chmod a+x Help | + | chmod a+x Steve |
| - | echo " | + | echo " |
| EndOfScript | EndOfScript | ||
| Line 139: | Line 142: | ||
| It should create a folder or two, and a script to use to make the tunnel. | It should create a folder or two, and a script to use to make the tunnel. | ||
| - | When the user needs assistance, have them run the 'Help' command, then, on your server, do the following; | + | When the user needs assistance, have them run the 'Steve' command, then, on your server, do the following; |
| < | < | ||
| sudo su - secretuser | sudo su - secretuser | ||
| # You need access to the keys. | # You need access to the keys. | ||
| - | ssh -i ~/ | + | ssh -i ~/ |
| # This should log you in to their machine, as them. | # This should log you in to their machine, as them. | ||
| # Do what you need to do to fix any issues, have the user verify the work, then; | # Do what you need to do to fix any issues, have the user verify the work, then; | ||
| - | Help q | + | Steve q |
| # To shut down the session, or use ' | # To shut down the session, or use ' | ||
| - | # Until you run 'Help q' or 'Help x', the tunnel will persist, through restarts of either end. | + | # Until you run 'Steve q' or 'Steve x', the tunnel will persist, through restarts of either end. |
| </ | </ | ||
| Line 154: | Line 157: | ||
| < | < | ||
| Host Betty | Host Betty | ||
| - | Hostname localhost | + | |
| - | Port 2223 | + | Port 2223 |
| - | User betty | + | User betty |
| - | ForwardX11 yes | + | ForwardX11 yes |
| - | IdentityFile ~/ | + | IdentityFile ~/ |
| </ | </ | ||
| Then, when Betty calls needing assistance, all you need to type is 'ssh Betty' | Then, when Betty calls needing assistance, all you need to type is 'ssh Betty' | ||
| + | |||
| + | Another nice thing to do, create an entry in / | ||
| + | < | ||
| + | Cmnd_Alias SystemCTL = / | ||
| + | %sudo ALL = NOPASSWD: SystemCTL | ||
| + | </ | ||
| + | |||
| Note that the connections can be made as any user that has those keys, so if you copy AssistanceKey from secretuser to your own ~/.ssh/ then you shouldn' | Note that the connections can be made as any user that has those keys, so if you copy AssistanceKey from secretuser to your own ~/.ssh/ then you shouldn' | ||
| + | Another nice thing to do is to set up a [[Shared ' | ||
remote_assistance.1695413005.txt.gz · Last modified: by steve
