[Linux] SSH Config 連線設定檔指南

Intro

SSH的個人連線設定檔使用~/.ssh/config管理較為方便且是針對Host個別套用(如Git)。


設定

  • 檔案:~/.ssh/config

  • 使用:針對設定的Host別名快速連線:ssh host-alias-name


設定檔規範

Host alias-name    
HostName server.name      
Port port-number     
IdentitiesOnly yes    
IdentityFile ~/.ssh/private_ssh_file 
User username-on-remote-machine

設定範例

Host server.com
    Hostname 36.200.190.110
    User nick_tsai

Host gitlab
    Hostname gitlab.com
    IdentitiesOnly yes
    IdentityFile ~/pem/my-gitlab.pem
    Port 22
    User nick

Host alias1 alias2
    Hostname 36.200.190.110

Leave a Reply

Your email address will not be published. Required fields are marked *