ssh key 的生成与配置
生成 ssh key
ssh-keygen -C foo@bar -f ~/.ssh/key.ssh
[-C comment] [-f output_keyfile]
提示
-C参数用于指定公钥尾部的用户名@主机名组合。-f参数用于指定生成的密钥对文件名。
ssh 配置
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/key.ssh
ssh 登录跳板机
Host jumpserver
HostName 172.0.0.1
Port 2222
User userName
IdentityFile ~/.ssh/key.ssh
ssh jumpserver
scp 文件传输
Host dlservere
HostName 172.0.0.1
Port 22
User root
IdentityFile /path/of/key
scp dlservere:/remote/path/of/source /local/path/of/target
FAQ
- no matching host key type found. Their offer: ssh-rsa
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile /path/of/key
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa