Skip to main content
added 681 characters in body
Source Link
minorChaos
  • 329
  • 1
  • 6

Update: The comments indicate the cat <<EOF versus cat <<'EOF' partly hits the problem. One can obtain more control by creating a temporary file

echo 'echo This will expanded on remote: $VAR $(hostname; ls file) ' > file.$$
echo "echo This will be expanded locally: $VAR $(hostname; ls -l file) ' >> file.SS
echo "ls -l /dir/file # This list the remote file anyway " >> file.$$
ssh ....  < file.$$

or we can use backslash escapes:

ssh ....  <<EOF
echo This will expanded on remote: \$VAR \$(hostname; ls file)
echo This will be expanded locally: $VAR $(hostname; ls file)
ls -l /dir/file # This list the remote file anyway
EOF

(not tested)

Update: The comments indicate the cat <<EOF versus cat <<'EOF' partly hits the problem. One can obtain more control by creating a temporary file

echo 'echo This will expanded on remote: $VAR $(hostname; ls file) ' > file.$$
echo "echo This will be expanded locally: $VAR $(hostname; ls -l file) ' >> file.SS
echo "ls -l /dir/file # This list the remote file anyway " >> file.$$
ssh ....  < file.$$

or we can use backslash escapes:

ssh ....  <<EOF
echo This will expanded on remote: \$VAR \$(hostname; ls file)
echo This will be expanded locally: $VAR $(hostname; ls file)
ls -l /dir/file # This list the remote file anyway
EOF

(not tested)

added 196 characters in body
Source Link
minorChaos
  • 329
  • 1
  • 6

Short answer: Either you have the keys on remote and you just forgot the ticks 'EOF' OR you have the keys on locale and vainly hope this is way to transfer the key over to the remote. In the second case transfer,transfer your key to remote by some other secure way (like scp -p) or upload your remote public identity key (assuming you generated one already) to bitbucket.

Long answer:

Just type ssh-agent see to what is happening here.

(Or

cat  << EOF
     echo Would do remotely   eval $(ssh-agent)
     echo Would do remotely   ssh-add ~/route/to/key
     echo -------------
EOF

or

ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << EOF
     echo WOULD DO   eval $(ssh-agent)
     echo WOULD DO   ssh-add ~/route/to/key
EOF

in the case you feel I am suggesting unrelated nonsense.)

The output contains something like

SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEEUQSV/agent.43806

which is Unix domain socket address of your ssh-agent on the local machine. This is local to your machine and does not exist (hopefully!) on the remote machine.

Such socket file does not exist on both of the machines. May be you wanted to write

#  Note  ' ' on the following line -----------------here-------------\--\
ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << 'EOF'
     eval $(ssh-agent)
     ssh-add ~/route/to/key
     ... rest of build script ...
EOF

if ~/route/to/key is valid on the remote machine.

Remark. If you know what you are doing, you could try also something like ssh-agent bash -c 'ssh-add ~/route/to/key; ssh -A -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}"'

Short answer: Either you have the keys on remote and you just forgot the ticks 'EOF' OR you have the keys on locale and vainly hope this is way to transfer the key over to the remote. In the second case transfer your key to remote by some other secure way (like scp -p) or upload your remote public identity key (assuming you generated one already) to bitbucket.

Long answer:

Just type ssh-agent see to what is happening here.

(Or

cat  << EOF
     echo Would do remotely   eval $(ssh-agent)
     echo Would do remotely   ssh-add ~/route/to/key
     echo -------------
EOF

or

ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << EOF
     echo WOULD DO   eval $(ssh-agent)
     echo WOULD DO   ssh-add ~/route/to/key
EOF

in the case you feel I am suggesting unrelated nonsense.)

The output contains something like

SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEEUQSV/agent.43806

which is Unix domain socket address of your ssh-agent on the local machine. This is local to your machine and does not exist (hopefully!) on the remote machine.

Such socket file does not exist on both of the machines. May be you wanted to write

#  Note  ' ' on the following line -----------------here-------------\--\
ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << 'EOF'
     eval $(ssh-agent)
     ssh-add ~/route/to/key
     ... rest of build script ...
EOF

if ~/route/to/key is valid on the remote machine.

Short answer: Either you have the keys on remote and you just forgot the ticks 'EOF' OR you have the keys on locale and vainly hope this is way to transfer the key over to the remote. In the second case ,transfer your key to remote by some other secure way (like scp -p) or upload your remote public identity key (assuming you generated one already) to bitbucket.

Long answer:

Just type ssh-agent see to what is happening here.

(Or

cat  << EOF
     echo Would do remotely   eval $(ssh-agent)
     echo Would do remotely   ssh-add ~/route/to/key
     echo -------------
EOF

or

ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << EOF
     echo WOULD DO   eval $(ssh-agent)
     echo WOULD DO   ssh-add ~/route/to/key
EOF

in the case you feel I am suggesting unrelated nonsense.)

The output contains something like

SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEEUQSV/agent.43806

which is Unix domain socket address of your ssh-agent on the local machine. This is local to your machine and does not exist (hopefully!) on the remote machine.

Such socket file does not exist on both of the machines. May be you wanted to write

#  Note  ' ' on the following line -----------------here-------------\--\
ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << 'EOF'
     eval $(ssh-agent)
     ssh-add ~/route/to/key
     ... rest of build script ...
EOF

if ~/route/to/key is valid on the remote machine.

Remark. If you know what you are doing, you could try also something like ssh-agent bash -c 'ssh-add ~/route/to/key; ssh -A -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}"'

Source Link
minorChaos
  • 329
  • 1
  • 6

Short answer: Either you have the keys on remote and you just forgot the ticks 'EOF' OR you have the keys on locale and vainly hope this is way to transfer the key over to the remote. In the second case transfer your key to remote by some other secure way (like scp -p) or upload your remote public identity key (assuming you generated one already) to bitbucket.

Long answer:

Just type ssh-agent see to what is happening here.

(Or

cat  << EOF
     echo Would do remotely   eval $(ssh-agent)
     echo Would do remotely   ssh-add ~/route/to/key
     echo -------------
EOF

or

ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << EOF
     echo WOULD DO   eval $(ssh-agent)
     echo WOULD DO   ssh-add ~/route/to/key
EOF

in the case you feel I am suggesting unrelated nonsense.)

The output contains something like

SSH_AUTH_SOCK=/tmp/ssh-XXXXXXEEUQSV/agent.43806

which is Unix domain socket address of your ssh-agent on the local machine. This is local to your machine and does not exist (hopefully!) on the remote machine.

Such socket file does not exist on both of the machines. May be you wanted to write

#  Note  ' ' on the following line -----------------here-------------\--\
ssh -i"${BUILDHOSTKEY}" "${BUILDHOSTUSERNAME}"@"${BUILDHOSTNAME}" << 'EOF'
     eval $(ssh-agent)
     ssh-add ~/route/to/key
     ... rest of build script ...
EOF

if ~/route/to/key is valid on the remote machine.