如何在Linux上设置SSH别名登录?
在 Linux 系统中,可以通过设置 ~/.ssh/config 文件来给服务器分配别名,方便使用 SSH 登录。该配置文件允许为每台服务器指定登录信息和验证方法,包括主机名、端口号、用户名、公钥文件和身份验证类型。
为了方便登录服务器,我们一般使用putty、securecrt等等工具。在终端如何通过服务器别名来进行登录呢?
可以创建~/.ssh/config 文件并为每台服务器指定登录信息和验证方法,如下所示:
$ vim ~/.ssh/config host www hostname www.ttlsa.com port 22 user root identityfile ~/.ssh/id_rsa.pub identitiesonly yes host bbs hostname 115.28.45.104 user anotheruser pubkeyauthentication no
然后直接指定别名进行登录
shell
$ ssh www
1 $ ssh www
选项注释:
hostname 指定登录的主机名或ip地址
port 指定登录的端口号
user 登录用户名
identityfile 登录的公钥文件
identitiesonly 只接受ssh key 登录
pubkeyauthentication
理论要掌握,实操不能落!以上关于《如何在Linux上设置SSH别名登录?》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注米云公众号吧!
