SSH 设置登录不同服务器

SSH(Secure Shell)

SSH 的配置文件有两个:

~/.ssh/config            # 用户配置文件
/etc/ssh/ssh_config # 系统配置文件

~/.ssh/config 文件配置

Host example                       # 关键词
HostName example.com # 主机地址
User root # 用户名
# IdentityFile ~/.ssh/id_ecdsa # 认证文件
# Port 22 # 指定端口

通过执行 $ ssh example 我就可以登录我的服务器。而不需要敲更多的命令 $ ssh root@example.com
又如我们想要向服务器传文件 $ scp a.txt example:/home/user_name。比以前方便多了。