SSH快捷登录设置

作者Veris 文章分类 分类:编程开发 文章评论 0条评论 阅读次数 已被围观 1279
客户端

1:打开~/.ssh,如果没有则创建文件夹

2:执行ssh-keygen -t rsa

    Enter file in which to save the key:输入保存私钥的文件名称(id_rsa_host)

    Enter passphrase (empty for no passphrase): (可以不写)

    Enter same passphrase again:(可以不写)

    此时会生成:id_rsa_host文件

3:ssh-add ~/.ssh/id_rsa_host,通过私钥创建公钥

    此时会生成:id_rsa_host.pub文件

 

服务端

1:打开~/.ssh,如果没有则创建文件夹

2:打开authorized_keys,将客户端第3步生成的文件中的公钥保存到此文件中,如果有多个则,换行处理

 

那么此时间已经可以直接连接服务器了

快捷连接设置

在客户端,~/.ssh下创建config文件,(window:config.config)

内容如下

Host hostFastConnection1
    HostName hostIp
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_host
    User username

Host hostFastConnection1
    HostName hostIp
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_host
    User username

完成,测试

ssh hostFastConnection1

回车即可

转自:https://my.oschina.net/yjpfj1203/blog/821165

分类:编程开发

发表评论: