$
:表明服務器環境shell
>
:表明本機環境安全
{Users}
:表明本機用戶名bash
<Users>
:表明服務器登陸用戶名服務器
衆所周知,登陸服務器有兩種驗證,密碼驗證以及證書驗證。本文以證書驗證的方式展開講解。ssh
絕大部分時候咱們經過耳熟能詳的工具能夠實現快速登陸。例如:工具
Windows 下:Putty、Xshell、SecureCRT、Finalshell測試
Mac 下:自帶終端、Putty、SecureCRT、Finalshellui
你們能夠根據實際狀況選擇一款或多款做爲平常工具。spa
證書好處不只在於能夠 安全 的訪問服務器,而且在操做大量服務器的時候顯得更 快速rest
> cd ~/.ssh
複製代碼
若是提示 cd: no such file or directory: /Users/{Users}/.ssh
則須要先配置 SSH 證書
輸入下列命令(郵箱能夠任意填寫)並連按三次回車
> ssh-keygen -t rsa -C "xx@xx.com"
複製代碼
默認會在 ~/.ssh目錄生成兩個文件: id_rsa(私鑰),id_rsa.pub(公鑰)
$ sudo vi /etc/ssh/sshd_config
複製代碼
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
複製代碼
$ sudo /sbin/service sshd restart
複製代碼
> ssh-copy-id <Users>@host
複製代碼
$ sudo chmod 700 ~/.ssh
$ sudo chmod 600 ~/.ssh/authorized_keys
複製代碼
> ssh '<Users>@host'
複製代碼
Command
+ P
喚醒 ProfilesCommand
+ shift
+ O
打開搜索框輸入寫好的 Name 便可快速訪問