跳到主要内容

ssh config 配置

本地ssh配置信息

~/.ssh/config

Host *
ServerAliveInterval 30


Host gitea.domain.com
Port 8322
  • 一个配置长时间保持与server的连接, 这样ssh后就不会经常掉线.
  • 一个用于配置ssh某站点时使用其他端口, 常用于独立部署的git站点

没有正确配置端口的话, git clone使用默认端口, 报错没有权限

git clone xxx

git@gitea.domain.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

ssh 使用 pem key登录

pem文件权限过大会导致无法登录

ssh管得还挺宽, 正确的pem密钥也会由于权限过大被拒绝登录.

(ocx)ssh ubuntu@1.1.1.1 -i gee_mac_home.pem
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'gee_mac_home.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "gee_mac_home.pem": bad permissions
ubuntu@1.1.1.1: Permission denied (publickey).

-rw-r--r--@   1 zhlin  staff   1.6K Apr  2 22:22 gee_mac_home.pem

修改所有者权限

chmod 700 gee_mac_home.pem

重新执行, 顺利登录

ssh ubuntu@1.1.1.1 -i gee_mac_home.pem
created at 2023-07-12