mac以ssh私钥认证方式登录ubuntu server

私钥认证方式可以规避暴力破解,机器扫描端口等网络安全风险,比如外网服务器,个人或公司购买的vps等。

1,在服务端创建密钥对。

     进入~/.ssh,执行ssh-keygen命令

2,安装公钥

  cat id_rsa.pub >> authorized_key

chmod 600 authorized_keys
chmod 700 ~/.ssh

3,设置 SSH,打开密钥登录功能

编辑 /etc/ssh/sshd_config 文件

 

RSAAuthentication yes
PubkeyAuthentication yes
PermitRootLogin ye

PasswordAuthentication no

service sshd restart

4,将私钥下载到客户端.scp命令下载至本地

5,创建config文件

#config_file

        Host "NAME"

        HostName "IP" 

        Port "22"

        User "USER"

        IdentityFile ~/.ssh/id_rsa



 

猜你喜欢

转载自www.cnblogs.com/htyjlitm/p/10045794.html