Linux上SSH登录远程服务器免密码
Posted 一个有点理想的码农
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux上SSH登录远程服务器免密码相关的知识,希望对你有一定的参考价值。
在本地的客户端SSH到远程服务端时,每次都要输入用户名和密码,如果不想每次都输入密码则可以使用以下操作。
首先在本地的客户端输入 ssh-keygen
[[email protected] ~]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/keysystem/.ssh/id_rsa): Created directory ‘/home/keysystem/.ssh‘. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/keysystem/.ssh/id_rsa. Your public key has been saved in /home/keysystem/.ssh/id_rsa.pub. The key fingerprint is: af:a4:d5:4d:96:3c:24:71:ea:37:47:0c:51:3b:ba:2b [email protected] The key‘s randomart image is: +--[ RSA 2048]----+ | . +o. | | + o . | | o . = | | . + + . | | S . X . | | o = = | | o o o | | + .E . | | . . .. | +-----------------+ [[email protected] ~]$
生成公私钥对,可以进入到~/.ssh目录下查看生成的公私钥对。
[[email protected] ~]$ cd ~/.ssh/ [[email protected] .ssh]$ ll -rlt total 8 -rw-r--r--. 1 keysystem keysystem 413 Dec 4 22:12 id_rsa.pub -rw-------. 1 keysystem keysystem 1675 Dec 4 22:12 id_rsa [[email protected] .ssh]$
然后执行 ssh-copy-id [email protected],其中dzy为远程主机的用户名,172.20.16.42为远程服务器的IP地址。
[[email protected] ~]$ ssh-copy-id [email protected]172.20.14.42
以上是关于Linux上SSH登录远程服务器免密码的主要内容,如果未能解决你的问题,请参考以下文章