ssh-keygen -t rsa -b 4096 -C "My key"cat ~/.ssh/id_rsa.puband then copy the output.
# On your server
mkdir -p ~/.ssh && echo your_key >> ~/.ssh/authorized_keys
chmod -R go= ~/.ssh# On your machine
nano ~/.ssh/configExample:
Host myserver
HostName server_ip
Port 22
User root
Ctrl+O, Ctrl+X
ssh myserverrm -rf /etc/apt/sources.list.d/*
nano /etc/apt/sources.listContents of the file:
deb http://deb.debian.org/debian sid main
deb-src http://deb.debian.org/debian sid main
Ctrl+O, Ctrl+X
7. Install KernelCollector (recommended)
echo "deb https://deb.tohka.us sid main" | sudo tee /etc/apt/sources.list.d/tohka.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E4012B02CD659038apt update && apt -y upgradereboot nowadduser newuser
usermod -aG sudo newuser
sudo su - newusermkdir -p ~/.ssh && echo your_key >> ~/.ssh/authorized_keys
chmod -R go= ~/.sshMake sure that on a separate terminal tab on your local machine, you change the User value to the new user's name in your ~/.ssh/config and test the connection.
sudo apt install git build-essential curl zip unzip wget ufwsudo ufw allow 22 # temporary, as we're changing ports later
sudo ufw enablesudo nano /etc/ssh/sshd_configDo the following changes:
- Uncomment
Portand set it to an arbitrary number (I prefer 2xxxx) - Uncomment
PermitRootLoginand set it tono - Uncomment
PubkeyAuthenticationand set it toyes - Uncomment
PasswordAuthenticationand set it tono
sudo ufw allow [new_port_number]
sudo service sshd restartOn your local machine, open a new terminal tab and test your connection by modifying the port number in ~/.ssh/config.
ssh-keygen -t rsa -b 4096 -C "My server"
cat ~/.ssh/id_rsa.pubYou should add this to your Github profile.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - # or whatever version you prefer
sudo apt install -y nodejsecho "prefix = ${HOME}/.npm/node_modules" >> ~/.npmrc
echo "export PATH=$HOME/.npm/node_modules/bin:$PATH" >> ~/.bashrc
source ~/.bashrcsudo apt install nginxsudo nano /etc/nginx/sites-available/mysite.confmysite.conf:
server {
listen 80;
server_name your_domain;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}(replace 8080 with your desired port)
sudo ln -s /etc/nginx/sites-available/mysite.conf /etc/nginx/sites-enabled/mysite.conf
sudo service nginx restartsudo apt install mysql-server
sudo mysql_secure_installation(note: I don't recommend using the validate password plugin, so say no to that)
sudo apt install php-fpmupstream php {
server unix:/var/run/php/php7.3-fpm.sock;
server 127.0.0.1:9000;
}
server {
listen 80;
server_name myphpwebsite.com;
root /home/myuser/php-project/;
index index.php index.html;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
# This is cool because no php is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}sudo apt install certbot python3-certbot-nginxsudo certbot --nginx