You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The provided documentation for cloning with an SSH key closely follows the code below. I keep getting an authentication error even after trying most of the closed-issue solutions in this repository. I suspect that the error is coming from libssh2 dependency because when I trace the bug it appears to be erroring out in remote.c.
The SSH key does work with the environment because it clones properly when using git in terminal
Error
Failed to clone: failed to start SSH session: Unable to exchange encryption keys; class=Ssh (23) 😡
FROM ubuntu:latest
# Update and install git and openssh-server
# Create the directory for the sshd server
RUN apt-get update && \
apt-get install -y git openssh-server && \
mkdir /var/run/sshd
# Switch to the git user and create the .ssh directory with git user permissions
RUN useradd -m git && \
su git -c "mkdir -p ~/.ssh && chmod 700 ~/.ssh && touch ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
# ⚠️ Must add the ssh key to the authorized_keys file see read me for more
RUN chmod 700 /home/git/.ssh && \
chmod 600 /home/git/.ssh/authorized_keys
RUN chown -R git:git /home/git/.ssh
# Create a folder for the git repositories
RUN su git -c "mkdir /home/git/repos"
# Create a test repository
RUN su git -c "cd /home/git/repos && git init --bare test.git"
# Expose the ssh port
EXPOSE 22
# Start the sshd server
CMD ["/usr/sbin/sshd", "-D"]
SSH key creation
ssh-keygen -t rsa -b 4096 -C "[email protected]"
I then put this key in the mount .ssh folder and put it in a file called authorized_keys.
Final Remark
I am just trying to get a test environment for a server set up so I can test it with my actual application. If anyone has an alternative approach.
The text was updated successfully, but these errors were encountered:
Its pretty simple, this is the line where the example code finds your ssh keys. std::path::Path::new(&format!("{}/.ssh/id_rsa", env::var("HOME").unwrap())),
Basically its looking at ~/.ssh/id_rsa while you're initializing ~/.ssh/authorized_keys to have your ssh info.
Changing the format! section to format!("{}/.ssh/authorized_keys"...) should do the trick.
Overview
The provided documentation for cloning with an SSH key closely follows the code below. I keep getting an authentication error even after trying most of the closed-issue solutions in this repository. I suspect that the error is coming from libssh2 dependency because when I trace the bug it appears to be erroring out in remote.c.
The SSH key does work with the environment because it clones properly when using git in terminal
Error
Failed to clone: failed to start SSH session: Unable to exchange encryption keys; class=Ssh (23) 😡
Code
Rust Code
Enviroment
docker-compose.yml
dockerfile
SSH key creation
ssh-keygen -t rsa -b 4096 -C "[email protected]"
I then put this key in the mount .ssh folder and put it in a file called authorized_keys.
Final Remark
I am just trying to get a test environment for a server set up so I can test it with my actual application. If anyone has an alternative approach.
The text was updated successfully, but these errors were encountered: