0

I'm not quite sure what the issue is. I'm on Kali Linux 2.0 right now, fresh install. The following worked on Ubuntu 14.04 but it's not working anymore (maybe I accidentally changed it?). It looks correct to me, but every time it runs it blocks.

backup_folder=$(ssh -i /home/dexter/.ssh/id_rsa $server 'ls -t '$dir' | head -1')

This is part of a larger script. $server and $dir are set. When I run the command alone, I get the correct output, but it doesn't end the connection.

1
  • no luck with my answer, i've extended with a third option. Can you provide some feedback? Thank you! Commented Oct 19, 2015 at 9:05

1 Answer 1

1

I don't know if this may help to solve the question but your command doesn't handle dirs with space in the filename. Add double quotes inside the single quote section like this:

SERVER='remoteServer' && REMOTE_DIR='remoteDir' && backup_folder=$(ssh -i /home/dexter/.ssh/id_rsa "${SERVER}" 'ls -t "'${REMOTE_DIR}'" | head -n1'); echo "${backup_folder}"

If it doesn't help try to add increasing number of -v switch to ssh to debug eventually reaching:

SERVER='remoteServer' && REMOTE_DIR='remoteDir' && backup_folder=$(ssh -vvv -i /home/dexter/.ssh/id_rsa "${SERVER}" 'ls -t "'${REMOTE_DIR}'" | head -n1'); echo "${backup_folder}"

If the verbose output does not help may be an MTU problem (these kind of problems are not of binary type, acts strangely).

You can try lowering MTU (usually 1500) on your side to solve:

sudo ifconfig eth0 mtu 1048 up

eth0 is obviously an example interface, use your own.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.