ssh配置config檔案

2021-08-08 15:43:28 字數 1030 閱讀 7451

在使用ssh連線伺服器時,經常要輸入一些不同的主機位址和密碼,使用config檔案可以很好的解決這個問題。

在配置之前我們先生成ssh金鑰。

# 使用以下命令 一路回車即可

ssh-keygen -t rsa

# 為.ssh目錄設定許可權

chmod 600 ~/.ssh/config

config檔案配置十分簡單,只需要按照以下格式配置即可。

# config檔案需要放到 ~/.ssh/config

host work1

hostname 121.0.0.3

user root

port 22

host work2

hostname 121.0.0.4

user root

port 22

將config檔案放到當前使用者home下的.ssh/目錄下之後需做如下操作來完成免密碼登陸:

# 將金鑰copy到work1,需要輸入work1的登陸密碼(此登陸密碼為config重配置的user密碼)

ssh-copy-id work1

# 成功後會有如下提示

now try logging into the machine, with: "ssh 'work1'"

and check to make sure that only the key(s) you wanted were added.

#現在使用如下即可登陸work1(其他主機方法一樣)

ssh work1

錯誤解決:

jone@ubuntu:$ ssh main

bad owner or permissions on /home/jone/.ssh/config

如果出現上述提示需要給.ssh目錄加許可權

chmod 600 .ssh/config

SSH配置config檔案連線目標伺服器

host route ip hostname route ip name user route user stricthostkeychecking no 取消首次連線的驗證提示 identityfile e abc abc rsa proxycommand e secret connect.exe...

讀取配置config檔案

123 from fish.q.li newegg.com 45 67讀取上面 的xml 14 15 1617 18 configurationcollection typeof mykeyvaluesetting 19public class mykeyvaluecollection config...

Linux核心配置 config檔案

在命令列中,進入頂層核心目錄,並輸入命令make menuconfig,就可以啟動乙個基於選單的核心配置編輯器。從這裡開始,你可以訪問每個可用的配置引數,並生成乙個定製的核心配置。當你退出配置編輯器時,它會提示你是否儲存修改,如果選擇儲存修改,全域性配置檔案.config就會被更新 如果不存在,則會...