腾讯云云服务器CVM系统工具配置

概述

腾讯云云服务器产品文档

腾讯云云服务器(Cloud Virtual Machine,CVM)是腾讯云提供的可扩展的计算服务。使用云服务器 CVM 避免了使用传统服务器时需要预估资源用量及前期投入,帮助您在短时间内快速启动任意数量的云服务器并即时部署应用程序。
云服务器 CVM 支持用户自定义一切资源:CPU、内存、硬盘、网络、安全等,并可以在需求发生变化时轻松地调整它们。

重装 CentOS 系统

云服务器控制台

重装系统

本示例中安装的是 CentOS 7.9 64位 Linux 系统:
CentOS 7.9 64位

登录服务器终端

SecureCRT 登录云服务器

SecureCRT

网页登录

网页登录


SSH 免密登录

为云服务器机器(root用户)生成公私钥:

1
ssh-keygen -t rsa -C "94xxxxxx87@qq.com"

mac 机器终端免密登录至腾讯云服务器

1
2
# ssh-copy-id 将 mac本机的公钥复制到腾讯云服务器机器的`authorized_keys`文件中
ssh-copy-id -i ~/.ssh/id_rsa.pub root@49.234.217.26

此时在终端中查看 ~/.ssh/authorized_keys 文件中已经存在 mac本机的公钥了。

至此,可以通过 ssh 'root@49.234.217.26' 指令,在 mac本机终端远程登录腾讯云云服务器。

添加普通用户coder

注意一般我们不适用 root 去进行开发,这里我们新建用户 coder 并配置 ssh 免密登录:

1
2
3
4
5
6
7
8
# 添加用户 coder
useradd coder
# 设置 coder 密码
passwd coder
# 切换到 coder 用户
su coder
# 显示用户信息
/usr/bin/id

ssh 免密登录

为 coder 用户生成公私钥:

1
ssh-keygen -t rsa -C "luxxxxxxxxng@qq.com"

ssh-copy-id 将 mac本机的公钥复制到腾讯云服务器机器的authorized_keys文件中,并通过 ssh 'coder@49.234.217.26' 指令以 coder 用户登录腾讯云云服务器:

coder 用户使用 sudo

默认新建的 coder 用户是不可以使用 sudo 指令的。(coder is not in the sudoers file. This incident will be reported.)

方法一:将一般用户coder加在管理员组wheel组中

1
2
3
4
5
6
7
# 需要 root 用户登录执行
# 将 coder 用户添加至管理员组wheel组中
usermod -G wheel coder
# 更新wheel用户组
newgrp wheel
# 查询wheel用户组的所有用户
groupmems -g wheel -l
1
2
3
4
# 切换 coder 用户
su coder
# 使用 sudo 执行 yum update 更新
sudo yum update

方法二:修改/etc/sudoers文件设置coder用户权限

1
2
3
4
5
6
7
# 改变文件sudoers的权限为可写
chmod 740 /etc/sudoers
vim /etc/sudoers
# 添加 `coder ALL=(ALL) NOPASSWD:ALL` (在使用sudo时不需要输入密码)

# 保存退出后,把sudoers的权限改为默认的440
chmod 440 /etc/sudoers

应用程序安装

查看云服务器系统磁盘使用情况统计:

1
df -hl

我们选择在 /dev/vda1 磁盘 /home/coder 目录下进行安装。

安装 nodejs

Node.js环境安装

安装 Docker

Docker环境安装

VS Code Remote SSH配置

VS Code Remote SSH配置