# This is the ssh client system-wide configurationfile. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# oron the command line.
步驟如下:
配置你的ssh_config文件(一般在/etc/ssh目錄下)如下:
Host 98//這裏是設置你的連接的一個別名
Hostname 111.111.111.111//設置ip
Port 56789//設置端口號
User wangsan //設置登錄名
PasswordAuthentication no //是否需要密碼認證,如果是sshkey認證,則no
ForwardAgent yes //是否需要轉發key到代理服務器,如果需要通過跳轉機連接同學,這裏需要填寫yes
AddKeysToAgent yes //將key添加到sshkey轉發列表
IdentityFile ~/.ssh/98/id_rsa //這裏是你生成的私鑰地址,對應的公鑰也需要放入id_rsa.pub
~/.ssh/identity
~/.ssh/id_dsa
~/.ssh/id_ecdsa
~/.ssh/id_ed25519
~/.ssh/id_rsa
Contains theprivate key for authentication. These files contain sensitive data and should be readable bythe user but not accessible by others (read/write/execute). ssh will simply ignore aprivate key fileifit is accessible by others. It is possible to specify a passphrase when generating the key which will be used toencryptthe sensitive part of this fileusing3DES.
也就是私鑰文件因爲安全需要,不能被其他用戶訪問,如果訪問安全不夠,則會默認忽略該私鑰。
具體怎麼改?
修改權限:
1.把從.ssh到獲取密鑰之間的目錄權限修改成700,上面的例子我們需要修改98目錄的權限:chmod 700 目錄
2.把私鑰文件權限修改成600:chmod 600 私鑰文件
3.查看當前登錄用戶 whoami
4.修改私鑰所有者爲自己 chown 當前用戶