ssh连接阿里云
  1. 设置root账户密码
    刚刚购买过后的服务器实例是没有密码的。
    需要在—实力详情基本详情更多设置一下root账号的密码
  2. 通过ssh连接云服务器
    1
    2
    3
    4
    $ssh root@xxx.xxx.xxx.xxx #服务器的公网ip
    $root@xxx.xxx.xxx.xxx's password: #输入设置过的root密码
    $Welcome to Alibaba Cloud Elastic Compute Service ! #连接成功
添加新用户

root权限是服务器的最高权限,平时尽量避免使用root权限直接操作。
可以通过新建用户并赋予root的权限。平时使用这个用户使用服务器,在有需要root权限的操作时通过添加sudo来获取root权限

1
2
3
4
5
6
7
8
$ useradd 新用户名 #添加新用户
$ passwd 新用户名 #设置密码
Changing password for user 新用户名.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
$ gpasswd -a 用户名 wheel #分配用户到wheel用户组 centOS wheel用户组默认有root权限

用户相关其他操作

1
2
$ ls –l /home #查看用户
$ userdel -rf name #删除名称为name的用户。
禁止root远程登录
1
2
3
sudo vi /etc/ssh/sshd_config
/PermitRootLogin #Yes改为No
sudo systemctl reload sshd #重载文件