Last active
November 17, 2024 09:36
-
-
Save roommen/18cd78d07b0fbc962de4e79c1d468f92 to your computer and use it in GitHub Desktop.
OpenSSH Update Script - Amazon Linux 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo yum install gcc -y | |
sudo yum install openssl-devel -y | |
sudo yum install zlib-devel -y | |
sudo yum install mlocate -y | |
sudo yum install autoconf -y | |
wget https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-9.1p1.tar.gz | |
tar zxvf openssh-9.1p1.tar.gz | |
cd openssh-9.1p1 && ./configure && make && sudo make install |
I am use centOS 7.6, it should like this
./configure --with-ssl-dir=/usr/local/openssl
smh this broke my clones
sed -i '129a\#include <systemd/sd-daemon.h>' sshd.c sed -i '2095a\ /* Signal systemd that we are ready to accept connections */' sshd.c sed -i '2096a\ sd_notify (0, "READY=1");' sshd.c
Hi everyone, I also updated OpenSSH on EC2 this week. After performing the above steps,
systemctl restart sshd executes successfully but the client cannot connect via ssh.
I think there may be some problem with the original ec2 sshkey after the update?
Has anyone else encountered a similar situation and fixed it?
Hope to get the answer... QQ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If your colleague also decided to follow these instructions on your day-off, and now finds themselves in a situation where the OpenSSH server is almost inaccessible anymore for new connections (e.g.
ssh your-server-ip
returns with error "kex_exhcnage_identification: read: Connection reset by peer"), follow my instructions to restore everything back.Assuming you (or your coworker) still have an open SSH connection and can run commands in the shell:
sudo passwd
(you can use tools like pwgen to generate a strong password).systemctl stop sshd; killall sshd
cd /home/ec2-user/openssh-9.1p1
make uninstall
to clean up all the files installed by the previous "make install" command (please avoid doing this on any non-personal machines in the future).yum reinstall openssh openssh-server openssh-client
systemctl start sshd
, and check if you can connect to the server from the server itself byssh localhost
.P.S. If upgrading is necessary to make npm work (due to the unsupported option "accept-now"), you can use this workaround by setting an environment variable:
GIT_SSH_COMMAND=ssh npm i ...
(Source)