fix chmod error for remote files using sudo
add remote directory functionality
cleanup remote_dir