目录
- 用户管理
- 查看端口情况
用户管理
新增
adduser kgl
Adding user `kgl' ...
Adding new group `kgl' (1001) ...
Adding new user `kgl' (1001) with group `kgl' ...
Creating home directory `/home/kgl' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: <== 输入密码
Retype new UNIX password: <== 确认密码
passwd: password updated successfully
Changing the user information for kgl
Enter the new value, or press ENTER for the default
Full Name []: <== 回车
Room Number []: <== 回车
Work Phone []: <== 回车
Home Phone []: <== 回车
Other []: <== 回车
Is the information correct? [Y/n] y
添加sudo权限
usermod -aG sudo kgl
密钥登录
- 生成密钥对
ssh-keygen<== 生成
Generating public/private rsa key pair.
Enter file in which to save the key (/home/kgl/.ssh/id_rsa): <== 回车
Created directory '/home/kgl/.ssh'.
Enter passphrase (empty for no passphrase): <== 回车
Enter same passphrase again: <== 回车
Your identification has been saved in /home/kgl/.ssh/id_rsa.
Your public key has been saved in /home/kgl/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:xd2DSlXACa1YI2rqEz2HyqlGHLFY9UKFW7qdxtDavkA kgl@iZwz92qfb6ao9koavdyhcfZ
The key's randomart image is:
- 配置公钥到服务器
sudo vi authorized_keys<== 在.ssh文件夹下生成authorized_keys文件,并把id_rsa.pub的内容复制进去
sudo: unable to resolve host iZwz92qfb6ao9koavdyhcfZ
[sudo] password for kgl: <== 输入登录密码
- 使用私钥登录
- 将id_rsa下载到本地
-
将私钥导入客户端(这里用的是Xshell),就能够登录了
查看端口情况
查看某个端口是否被占用
lsof -i:端口号
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 21024 root 4u IPv6 72930 0t0 TCP *:mysql (LISTEN)
网友评论