| 第35行: | 第35行: | ||
# vim /etc/ssh/sshd_config | # vim /etc/ssh/sshd_config | ||
Port 54194 | |||
PermitRootLogin no | PermitRootLogin no | ||
PasswordAuthentication no | PasswordAuthentication no | ||
| 第41行: | 第42行: | ||
service ssh restart | service ssh restart | ||
ssh -p 50000 ubuntu@12.98.23.12 | ssh -p 50000 ubuntu@12.98.23.12 | ||
</syntaxhighlight> | |||
Note: for Ubuntu 24.04+ with systemd socket | |||
<syntaxhighlight lang="bash"> | |||
# To change the port | |||
sudo vim /lib/systemd/system/ssh.socket | |||
[Socket] | |||
ListenStream=0.0.0.0:54194 | |||
ListenStream=[::]:54194 | |||
sudo systemctl daemon-reload | |||
sudo systemctl stop ssh.socket | |||
sudo systemctl restart ssh | |||
netstat -anp | grep 54194 | |||
(No info could be read for "-p": geteuid()=1000 but you should be root.) | |||
tcp 0 0 0.0.0.0:54194 0.0.0.0:* LISTEN - | |||
tcp6 0 0 :::54194 :::* LISTEN - | |||
</syntaxhighlight> | </syntaxhighlight> | ||
2026年3月28日 (六) 14:03的最新版本
Ubuntu server setup:
System settings
Add admin user:
adduser sammy
usermod -aG sudo sammy
su - sammy
Update system
sudo apt update
sudo apt upgrade
do-release-upgrade
reboot
hostname
vim /etc/hostname
user
adduser ubuntu
usermod -aG sudo ubuntu
ssh config
ssh-copy-id -p 50000 ubuntu@12.98.23.12
# vim /etc/ssh/sshd_config
Port 54194
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
service ssh restart
ssh -p 50000 ubuntu@12.98.23.12
Note: for Ubuntu 24.04+ with systemd socket
# To change the port
sudo vim /lib/systemd/system/ssh.socket
[Socket]
ListenStream=0.0.0.0:54194
ListenStream=[::]:54194
sudo systemctl daemon-reload
sudo systemctl stop ssh.socket
sudo systemctl restart ssh
netstat -anp | grep 54194
(No info could be read for "-p": geteuid()=1000 but you should be root.)
tcp 0 0 0.0.0.0:54194 0.0.0.0:* LISTEN -
tcp6 0 0 :::54194 :::* LISTEN -
ufw
sudo ufw enable
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 50000
sudo ufw status numbered
V2ray
Web server
Ngnix
$ sudo apt install nginx
$ sudo systemctl status nginx
Certbot
Install via pip[1]
sudo apt install certbot
sudo apt install python3 python3-dev python3-venv libaugeas-dev gcc
sudo python3 -m venv /opt/certbot/
sudo /opt/certbot/bin/pip install --upgrade pip
sudo /opt/certbot/bin/pip install certbot certbot-nginx
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
sudo certbot --nginx
sudo nginx -s reload