Created
September 22, 2016 13:35
-
-
Save jtyr/1083182228d78beda55aae2c8e9774d0 to your computer and use it in GitHub Desktop.
Set of steps which help to reproduce the issue when connection with sshpass through a proxy
This file contains 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
# Create SSH keys to be able to use localhost as the proxy | |
ssh-keygen | |
cat ~/.ssh/id_rsa.pub > ~/.ssh/authorized_keys | |
chmod 600 ~/.ssh/authorized_key | |
chmod 700 ~/.ssh | |
# Create the SSH config | |
cat >~/.ssh/config <<END | |
Host * | |
# !!!Make sure this directory exists!!! | |
ControlPath ~/.ssh/cp/%r@%h:%p | |
ControlMaster auto | |
ServerAliveInterval 60 | |
ServerAliveCountMax 2 | |
StrictHostKeyChecking no | |
UserKnownHostsFile /dev/null | |
ControlPersist 1h | |
Host proxy | |
HostName localhost | |
Host remote_no_proxy | |
HostName 10.129.1.236 | |
Host remote_via_proxy | |
HostName 10.129.1.236 | |
ProxyCommand ssh -l $USER -q proxy nc %h %p | |
END | |
# Create a file with the remote user password | |
echo "mypassword" > ./pass.txt | |
# Close all connections | |
pkill -x ssh | |
# This creates the control file for the remote and the file stays even after the command finished: | |
sshpass -f pass.txt ssh -l remote_user remote_no_proxy 'sleep 2' | |
# Close all connections | |
pkill -x ssh | |
# This creates the control file for both, the proxy and remote but after the command finished, the SSH session gets closed with "packet_write_wait: Connection to UNKNOWN port 0: Broken pipe" and the control file for the remote disappears: | |
sshpass -f pass.txt ssh -l remote_user remote_via_proxy 'sleep 2' | |
# Close all connections | |
pkill -x ssh | |
# This creates the control file for both, the proxy and the remote and both stay even after the command finished: | |
ssh -l remote_user remote_directly 'sleep 2' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment