Skip to content

Instantly share code, notes, and snippets.

@kowalcj0
Created December 15, 2020 23:55
Show Gist options
  • Save kowalcj0/3b3195d5687bbd0e9b72cef1783cd97a to your computer and use it in GitHub Desktop.
Save kowalcj0/3b3195d5687bbd0e9b72cef1783cd97a to your computer and use it in GitHub Desktop.
Install endlessh
# get latest version
wget https://github.com/skeeto/endlessh/archive/master.zip
unzip master.zip
cd endlessh-master/
# compile
make
# install
sudo cp endlessh /usr/local/bin/
sudo cp util/endlessh.service /etc/systemd/system/
# create config
sudo mkdir /etc/endlessh
# add whatever option you want to config file
sudo tee /etc/endlessh/config << END
Port 22
Delay 10000
MaxLineLength 32
MaxClients 4096
LogLevel 0
BindFamily 0
END
# allow Endlessh to bind on ports < 1024
sudo setcap 'cap_net_bind_service=+ep' /usr/local/bin/endlessh
# enable & start the service
systemctl daemon-reload
systemctl enable --now endlessh.service
systemctl start endlessh.service
systemctl status endlessh.service
@binarweb
Copy link

I would improve your script by:

  • changing the permissions for the endlessh.service file from your normal user to root
sudo chown root:root /etc/systemd/system/endlessh.service
  • creating a no shell user and use that in the endlessh.service file (as running a service under root user is not advised)
sudo adduser --system --no-create-home --disabled-login --group endlessh
sudo nano /etc/systemd/system/endlessh.service

and add

[Service]
User=endlessh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment