第一步:产生key
ssh-keygen -b 密匙长度 -t 密匙类型
密匙类型可以是:rsa1 (对应SSH1 RSA)、rsa 和 dsa (对应SSH2)如:
默认在~/.ssh下会生成 id_rsa和 id_rsa.pub
id_rsa是private key,
id_rsa.pub是public key (密钥类型 RSA,密钥长度 1024)。
把id_rsa.pub 复制为authorized_keys(仍然在.ssh目录)
第二步:设置Linux或Mac客户端主机
复制私钥到客户linux机
scp server_hostname:/home/username/.ssh/remmot_id_rsa/id_rsa
接下里就可以用ssh直接执行远程linux命令了
ssh -i /home/username/.ssh/remmot_id_rsa/id_rsa username@server_hostname <linux command>
ssh-keygen -b 密匙长度 -t 密匙类型
密匙类型可以是:rsa1 (对应SSH1 RSA)、rsa 和 dsa (对应SSH2)如:
- ssh-keygen -b 1024 -t rsa
默认在~/.ssh下会生成 id_rsa和 id_rsa.pub
id_rsa是private key,
id_rsa.pub是public key (密钥类型 RSA,密钥长度 1024)。
把id_rsa.pub 复制为authorized_keys(仍然在.ssh目录)
第二步:设置Linux或Mac客户端主机
复制私钥到客户linux机
scp server_hostname:/home/username/.ssh/remmot_id_rsa/id_rsa
接下里就可以用ssh直接执行远程linux命令了
ssh -i /home/username/.ssh/remmot_id_rsa/id_rsa username@server_hostname <linux command>
如果私钥复制到客户Linux/Mac机的家目录的.ssh子目录(名字保持不变),则不需要-i参数。
window登录可以使用工具选择sshkey