目錄
- 用戶管理
- 查看端口情況
用戶管理
新增
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: <== 確認(rèn)密碼
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權(quán)限
usermod -aG sudo kgl
密鑰登錄
- 生成密鑰對(duì)
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:
- 配置公鑰到服務(wù)器
sudo vi authorized_keys<== 在.ssh文件夾下生成authorized_keys文件膜钓,并把id_rsa.pub的內(nèi)容復(fù)制進(jìn)去
sudo: unable to resolve host iZwz92qfb6ao9koavdyhcfZ
[sudo] password for kgl: <== 輸入登錄密碼
- 使用私鑰登錄
- 將id_rsa下載到本地
-
將私鑰導(dǎo)入客戶端(這里用的是Xshell)嗽交,就能夠登錄了
查看端口情況
查看某個(gè)端口是否被占用
lsof -i:端口號(hào)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
docker-pr 21024 root 4u IPv6 72930 0t0 TCP *:mysql (LISTEN)