我想将我的 SSH key 添加到 git 服务器(公司服务器)上的授权 key ,这样就不必在每次推送时都输入密码。但是由于某种原因,我无法使它正常工作。
我尝试过的:
ssh-copy-id user@server
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
user@server's password:
fatal: unrecognized command '
umask 077 ;
mkdir -p .ssh && cat >> .ssh/authorized_keys || exit 1 ;
if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'
当我尝试通过 ssh 连接到 git 服务器时,我得到以下响应:
fatal: Interactive git shell is not enabled.
hint: ~/git-shell-commands should exist and have read and execute access.
显然用户帐户正在使用 git-shell
并且它似乎不理解通常的 shell 命令。
是否仍然可以通过某种方式将公共(public) SSH key 添加到 git 服务器用户帐户?是否有一些 git 命令可以让我将我的公共(public) SSH key 添加到列表中?
我对 git 服务器的唯一访问是通过命令行,并且 GitWeb 界面正在运行(但在那里我也没有看到任何安装 SSH key 的选项)。
最佳答案
你应该联系你的系统管理员,确保用户主目录权限没有其他人的写权限。
对于 /home/user/.ssh
权限建议是它的组并拥有 0700
和 /home/user/authorized_keys
权限 0600
。
我假设 user
组是 git
。
# cd /home/user
# chown -R user:git .ssh
# chmod 0700 .ssh
# chmod 0600 .ssh/authorized_keys
如果此文件(.ssh/authorized_keys
)、~/.ssh 目录
或用户的主目录可由其他用户写入,则该文件可能是未经授权的用户修改或更换。在这种情况下,sshd
将不允许使用它,除非 StrictModes
选项已设置为“no”。
更多信息请看man 8 sshd
关于git - 如何在 Git 服务器上插入 SSH key (仅限 git-shell 访问),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36082253/