1. 程式人生 > >mac以ssh私鑰認證方式登入ubuntu server

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