ssh-keygen -t rsa -b 4096 -C "My key"
cat ~/.ssh/id_rsa.pub
and 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/config
Example:
Host myserver
HostName server_ip
Port 22
User root
Ctrl+O, Ctrl+X
ssh myserver
rm -rf /etc/apt/sources.list.d/*
nano /etc/apt/sources.list
Contents 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 E4012B02CD659038
apt update && apt -y upgrade
reboot now
adduser newuser
usermod -aG sudo newuser
sudo su - newuser
mkdir -p ~/.ssh && echo your_key >> ~/.ssh/authorized_keys
chmod -R go= ~/.ssh
Make 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 ufw
sudo ufw allow 22 # temporary, as we're changing ports later
sudo ufw enable
sudo nano /etc/ssh/sshd_config
Do the following changes:
- Uncomment
Port
and set it to an arbitrary number (I prefer 2xxxx) - Uncomment
PermitRootLogin
and set it tono
- Uncomment
PubkeyAuthentication
and set it toyes
- Uncomment
PasswordAuthentication
and set it tono
sudo ufw allow [new_port_number]
sudo service sshd restart
On 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.pub
You 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 nodejs
echo "prefix = ${HOME}/.npm/node_modules" >> ~/.npmrc
echo "export PATH=$HOME/.npm/node_modules/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
sudo apt install nginx
sudo nano /etc/nginx/sites-available/mysite.conf
mysite.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 restart
sudo 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-fpm
upstream 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-nginx
sudo certbot --nginx