标签归档:VPS

Docker Container Restarting after SSH Login – Solution

As mentioned in a previous blog post, my current project is deployed using Docker. However, during a recent login to the server, a strange phenomenon occurred: all the containers in Docker would restart from time to time. Also, every time I logged in to check the Docker status, it would show that the containers had just started (Up 15 seconds). After several investigations, I finally identified that the restart issue was related to SSH login. Every time I logged in via SSH, the containers would restart.

继续阅读

Using Docker Compose to Self-host Project Deploy

After three months of hard work, the SSL certificate of my RSS aggregator finally expired. The auto-renew script failed to renew it — this happened a couple of times, I need to login into the web panel and renew it manually every three months. Unfortunately, the web panel malfunctioned this time either. After an epic battle with cert-bot, Nginx, and even the web panel I used, I finally gave up and decided to switch to another self-hosting solution.  

继续阅读

普通用户如何设置SSH密钥访问

普通用户建立SSH密钥实现无密码登陆

VPS操作中更加推荐使用普通用户登录SSH(避免root远程登陆),但直接设置会造成权限问题(尤其是之前配置过root用户使用密钥认证)。本文简单介绍普通用户配置SSH密钥访问的方法,具体原理请参加末尾参考部分。


 

首先建立普通用户并设置密码(推荐使用密码生成工具生成高强度密码)

建立用户

useradd lxfy

生成密码

passwd lxfy

随后在root身份下创立普通用户ssh文件夹

mkdir -m 777 /home/lxfy/.ssh

切换回普通用户,并生成公钥私钥。
略~
导入公钥到authorized_keys

cat id_rsa.pub > authorized_keys

修改权限

chmod 600 ~/.ssh/authorized_keys

删除公钥私钥

rm -rf id_rsa.pub
rm -rf id_rsa

重启SSH服务即可~

参考文章:
普通用户如何设置SSH无密码访问
SSH keys (简体中文) Archwiki