我正在尝试构建一个 ssh 服务以允许推/拉到 phabricator 存储库。我已经对所有服务进行了 docker 化,目前遇到了一个奇怪的错误,无法执行 ssh 必需的身份验证脚本。
docker 镜像同时运行php-fpm和sshd服务,其想法是将 ssh 与必需的 php 脚本结合起来。
特别是,我有以下 /etc/ssh/sshd_config:
AuthorizedKeysCommand /usr/libexec/phabricator-ssh-hook.sh
AuthorizedKeysCommandUser git
AllowUsers git
Port 2222
Protocol 2
PermitRootLogin no
AllowAgentForwarding no
AllowTcpForwarding no
PrintMotd no
#PrintLastLog no
PasswordAuthentication no
ChallengeResponseAuthentication no
AuthorizedKeysFile none
PidFile /var/run/sshd-phabricator.pid
Run Code Online (Sandbox Code Playgroud)
(顺便说一句,当我启动 sshd 时,PrintLastLog 抛出一个错误,我认为这不相关,但可能是?)
当我手动运行时
su - git -c "/srv/phabricator/scripts/ssh/ssh-auth.php git",我能够成功执行该脚本。
但是,当我sshd在调试模式 ( /usr/sbin/sshd -d -d -d) 下运行时检查日志时,收到以下错误:
...other stuff...
debug3: monitor_read: checking request 22
debug3: mm_answer_keyallowed …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一个项目推送给 dokku master。我只是使用 dokku 设置教程,当我到达这个阶段时
git push dokku master
Run Code Online (Sandbox Code Playgroud)
我收到一条消息
ssh: connect to host dokku.me port 22: Connection timed out
fatal: Could not read from remote repository
Run Code Online (Sandbox Code Playgroud)
所以在我的搜索中我发现我应该将我的 ssh 配置文件更改为此
# GITHUB
Host github.com
Hostname ssh.github.com
Port 443
Run Code Online (Sandbox Code Playgroud)
这仍然给出相同的错误。
当我使用命令时
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
我收到这条消息
warning: agent returned different signature type ssh-rsa (expected rsa-sha2-512)
Hi XXXX You've successfully authenticated, but GitHub does not provide shell access.
Run Code Online (Sandbox Code Playgroud)
关于为什么我无法连接到端口 22 或端口 443 有什么线索吗?这是我家里的本地机器,所以两个端口都不应该被阻止
我遵循了这些说明。
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
sshd在跑LISTENING然而,ssh: connect to host MY_IP port 22: Operation timed out当我尝试从网络外部的另一台设备远程访问时,我得到了。
我目前正在尝试使用 VS code 设置远程开发环境。
我已经安装了远程 - SSH 插件并编辑了我的 .ssh/config 文件,如下所示
主持人ABC
User ubuntu
HostName xx.xx.xx.xx
IdentityFile ~/.ssh/filename
Run Code Online (Sandbox Code Playgroud)
本地计算机 - Windows 主机 - Ubuntu(Linux)
请帮忙解决这个问题
2 天前,我能够使用 private_key.pem 和 ssh 协议连接到我的 EC2 实例,但今天当我尝试进行连接时,终端给了我:
\n权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic)
\n我删除了名为 jhon 的用户以及该用户的所有主页,然后再次创建并执行相同的步骤来创建公钥和私钥:
\n-- 我创建一个名为 jhon2.pem 的最新 .pem 文件,其中包含 id_rsa 内容(private_key)
\n从我的笔记本电脑上,我再次尝试了 ssh -i /home/macos/pems/jhon2.pem jhon2@instance-id,但没有再出现...
\n我不\xc2\xb4t 知道发生了什么:s
\n编辑:我见过这种方法有效的情况和无效的情况,我不确定我何时/为何这样做。
假设我有一个足够复杂的条目,我在其中指定了多个参数thathost:
Host thathost
ControlMaster auto
ServerAliveInterval 8
ConnectTimeout 8
Hostname 192.168.5.1
User mememe
ProxyJump thejumpbox
Run Code Online (Sandbox Code Playgroud)
我想在创建其他条目时重新使用此定义,通过添加或覆盖某些配置来提供不同的功能。特别指定备用端口(不,我不想在命令行上使用它)。
理想情况下我能够做类似的事情
Host theirhost
Hostname thathost
User themthem
Run Code Online (Sandbox Code Playgroud)
或者
Host my-remote-serialport
Hostname thathost
RequestTTY yes
RemoteCommand some-script-that-launches-kermit-on-a-specific-dev-tty
Run Code Online (Sandbox Code Playgroud)
或者
Host my-remote-serialport
Hostname thathost
Port 3004
Run Code Online (Sandbox Code Playgroud)
我严格要求根据另一台现有主机来指定一台主机,我不想修改我的Host条目以匹配某些模式“技巧”。
显然,我可以利用ProxyCommand ssh -q nc thathost...or ProxyJump thathost+Hostname localhost后跟所有其他覆盖(对于端口覆盖来说,会将其传递给nc),但这既丑陋又浪费(额外的会话) - 请不要回答这个问题。
对我来说,这是 的缺失功能ssh-config,但也许我看起来不够仔细。
我有一个 ubuntu 20.04 容器。我已经安装了 openssl
root@sddfr4533:/# openssl version
OpenSSL 1.1.1n 15 Mar 2022
Run Code Online (Sandbox Code Playgroud)
尝试克隆某些包含 libcrypto.so.1.1 的项目时出现此错误
/usr/lib/git-core/git-remote-http: /software/bin/libcrypto.so.1.1: version `OPENSSL_1_1_1' not found (required by /lib/x86_64-linux-gnu/libssh.so.4)
Run Code Online (Sandbox Code Playgroud)
另外,当我尝试删除并重新安装 openssh (apt-get install openssh-server openssh-client) 时,我收到此错误:
Creating config file /etc/ssh/sshd_config with new version
Creating SSH2 RSA key; this may take some time ...OpenSSL version mismatch. Built against 1010106f, you have 1010007f
Run Code Online (Sandbox Code Playgroud)
我已经在这些线程上尝试过解决方案: OpenSSL 版本不匹配。针对 1000105f 构建,您有 10001080
和
我使用了一个由大约 30 台机器组成的集群,这些机器最近都用新的 OpenSSH 主机密钥进行了重新配置。当我尝试登录时,我收到此错误消息(为简洁起见,删除了许多行):
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
The fingerprint for the RSA key sent by the remote host is
52:bb:71:83:7e:d0:e2:66:92:0e:10:78:cf:a6:41:49.
Add correct host key in /home/nr/.ssh/known_hosts to get rid of this message.
Offending key in /home/nr/.ssh/known_hosts:50
Run Code Online (Sandbox Code Playgroud)
我可以手动删除违规行,在这种情况下,我会收到有关 IP 地址的不同抱怨,这需要手动删除另一行,而且我不想重复这个练习 29 次。我想写一个程序来做到这一点。不幸的是,.ssh 文件中的这一行不再像早期版本那样包含明文形式的主机名和 IP 地址。
所以这是我的问题:
~/.ssh/known_hosts商店的哪些行是该主机或 IP 地址的 SSH 主机密钥?如果我可以恢复这些信息,我想我可以自己完成其余的工作。
脚注:我更喜欢用 bash/ksh/sh 或 C 或 Lua 编码;我的 Perl 和 Python 非常生疏。
说明:
我不想删除整个文件并重新填充它;它包含一百多个经过验证的密钥,我不想重新验证这些密钥。
无论我维护一个主副本还是多个副本,清除大量过时的主机密钥的问题仍然存在。
这是我使用的 Lua …
我在sshd_config上添加了这些行
AuthorizedKeysCommand /authorizedkeys/authorized-keys
AuthorizedKeysCommandUser ssh-keys
-rwxr-x--- 1 root ssh-keys 712 Dec 23 22:36 /authorizedkeys/authorized-keys
-rwxr-x--- 1 root ssh-keys 712 Dec 23 22:36 authorized-keys
Run Code Online (Sandbox Code Playgroud)
ssh-keys用户可以执行该文件(/ authorizedkeys/authorized-keys).但我不能ssh到服务器; ssh git@myserver.com
在auth.log中我可以看到这一行,
error: Unsafe AuthorizedKeysCommand: bad ownership or modes for directory /
Run Code Online (Sandbox Code Playgroud)
如果我给/ authorizedkeys/authorized-keys文件授予770权限,我会收到以下错误,
error: Unsafe AuthorizedKeysCommand: bad ownership or modes for file /authorizedkeys/authorized-keys
Run Code Online (Sandbox Code Playgroud)
我尝试使用root作为AuthorizedKeysCommandUser并更改/ authorizedkeys/authorized-keys文件的权限和所有者.它也没用.
我在ubuntu 14.04上使用OpenSSH_6.6.1p1.
注意:我可以使用authorized_keys文件ssh
如何知道SSH密钥的长度?
我git pull最近收到以下错误,
$ git pull
> GitLab: Your SSH key must be at least 2048 bits.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
以前一切正常。
不是猜测(或试错)哪个密钥是罪魁祸首,是否可以列出我所有的 SSH 密钥长度?
更新:
只是git pull给了我上面的错误。即,我的公钥仍然很好:
$ ssh -T git@salsa.debian.org
Welcome to GitLab, @myid-guest!
Run Code Online (Sandbox Code Playgroud)这ssh-keygen -lf可能不是答案,因为我正在关注https://docs.gitlab.com/ee/ssh/,他建议将其ed25519用作默认密钥,并且还指示生成新的 ED25519 SSH 密钥对,做ssh-keygen -t ed25519 -C "email@example.com"。然而,我的ssh-keygen -lf报告说
$ ssh-keygen -lf id_ed25519.pub …Run Code Online (Sandbox Code Playgroud)我在使用 SSH 连接到运行 Alpine Linux 3.10 的Docker 容器(从此图像中)时遇到问题。
此连接必须使用 SSH,因为我使用的备份软件barman需要通过 SSH 连接到在 Docker 容器内运行的 PostgreSQL 11 数据库。
首先我使用连接到 docker 容器
docker exec -it <container_name> /bin/bash
Run Code Online (Sandbox Code Playgroud)
然后尝试重新安装并启动sshd
bash-5.0# apk add openssh --no-cache
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
OK: 117 MiB in 42 packages
bash-5.0# apk add openrc --no-cache
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.10/community/x86_64/APKINDEX.tar.gz
OK: 117 MiB in 42 packages
bash-5.0# rc-update add sshd
* rc-update: sshd already installed in runlevel `sysinit'; skipping
bash-5.0# /etc/init.d/sshd start
* WARNING: sshd is …Run Code Online (Sandbox Code Playgroud) openssh ×11
ssh ×8
docker ×2
linux ×2
ssh-keys ×2
alpine-linux ×1
amazon-ec2 ×1
centos ×1
dokku ×1
git ×1
key ×1
openssl ×1
phabricator ×1
ssh-config ×1
sshd ×1
ubuntu ×1