# 1. 基础连接
```shell
ssh 用户名@IP地址 -p Port
```
# 2. 配置修改
`vim /etc/ssh/sshd_config`
修改端口:`Port 222`
允许root登录:`PermitRootLogin yes`
允许密码登录:`PasswordAuthentication yes`
只允许使用密钥对登录:`PasswordAuthentication no`
# 3. 生成密钥对
```cmd
cd %userprofile%/.ssh
ssh-keygen -t ed25519 -b 4096
```
查看公钥文件:`type kali.pub`
粘贴到kali的`~/.ssh/authorized_keys`文件中,并且修改文件权限为600:`chmod 600 ~/.ssh/authorized_keys`。
使用私钥连接kali:
```shell
ssh 用户名@IP地址 -p Port -i %userprofile%/.ssh/kali
```
# 4. 别名
修改ssh客户端配置文件:`%userprofile%/.ssh/config`
```shell
host kali
hostname 10.0.6.142
user root
port 222
identityfile ~/.ssh/kali
```