赞
踩
先生成私钥,再生成公钥
ssh-keygen ---生成密钥对命令 Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): --保存密钥对路径 Enter passphrase (empty for no passphrase): 输入私钥的密码 Enter same passphrase again: 确认私钥的密码 Your identification has been saved in /root/.ssh/id_rsa. 私钥文件 Your public key has been saved in /root/.ssh/id_rsa.pub. 公钥文件---> 推送给服务端 The key fingerprint is: 11:c5:3a:1a:ad:ff:d2:48:f8:ac:d4:62:67:38:8a:5f root@xx The key's randomart image is: +--[ RSA 2048]----+ | .o. | | .. | | ... | | . +. | | =S. | | +o. | | E=+o | | . = =* . | | ..o .. o. | +-----------------+
方法一:
在服务端新建用户的存放公钥目录
mkdir /home/u02/.ssh/ && chmod 700 /home/u02/.ssh/
scp /root/.ssh/id_rsa.pub u02@192.168.0.2:/home/u02/.ssh/authorized_key
你需要远程主机那个用户,你就把公钥推送给那个用户 $HOME/.ssh/authorized_keys
方法二:
ssh-copy-id --只能使用默认端口22
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.0.2
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。