# 如何连接远程服务器？

有三类基本的ssh连接方式

1. ssh客户端连接：Win可以用[xshell](https://www.xshell.com/zh/free-for-home-school/)，Mac可以用[Royal TSX](https://www.royalapps.com/ts/mac/features)
2. [VSCode-Remote](https://zhuanlan.zhihu.com/p/655276102)
3. ssh直接连接（不常用但要会）`ssh -p PORT USER@SERVER_IP`

{% hint style="info" %}
如果你觉得输入密码太麻烦，可以设置公钥登录：

* 在本地生成密钥：`ssh-keygen -t ed25519`，
* 把生成的`~/.ssh/id_ed25519.pub` 的内容复制到服务器的`~/.ssh/authorized_keys`中。
  {% endhint %}
