Pre signing AWS S3 files - bash

I have a bucket that allows for open files. I have uploaded a test file called test.gsm and have tried to presign the file by doing
root#server2:~# aws s3 presign s3://dovid-ft/test.gsm --expires-in 604800
https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B%2FKVrqgOXFQNTGh3gme%2Fo%3D&Expires=1625658191
root#server2:~#
If I then try to grab that file I get a 403.
root#server2:~# wget 'https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B%2FKVrqgOXFQNTGh3gme%2Fo%3D&Expires=1625658191'
--2021-06-30 07:49:21-- https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B%2FKVrqgOXFQNTGh3gme%2Fo%3D&Expires=1625658191
Resolving dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)... 52.217.88.204
Connecting to dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)|52.217.88.204|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2021-06-30 07:49:21 ERROR 403: Forbidden.
root#server2:~#
I also tried to decode the HTML of the key to see if that would help and it did not.
root#server2:~# wget 'https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B/KVrqgOXFQNTGh3gme/o=&Expires=1625658191'
--2021-06-30 07:49:37-- https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B/KVrqgOXFQNTGh3gme/o=&Expires=1625658191
Resolving dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)... 52.217.32.100
Connecting to dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)|52.217.32.100|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2021-06-30 07:49:37 ERROR 403: Forbidden.
root#server2:~#
Is there any way to get logs or see what the issue is and why my request is being rejected? As of now the only way to be able to get the file is to make it publicly available which I don't want to do.

It turns out I was using the wrong credentials to presign the file. Why amazon didn't throw an error when I tried to presign them with the wrong credentials is beyond me.

The solution is in wget. after recreating the scenario I wasn't able to download a file via wget also.
wget -O test.gsm "https://yourURL" # and will do.
reference: Amazon AWS S3 signed URL via Wget

Related

wget on Debian Server gets 302 Found while wget on Manjaro gets 200 OK

I'm using wget to retrieve the Instagram JSON from the URL https://www.instagram.com/instagram/?__a=1.
Running wget from my local Manjaro setup returns a 200 OK and the proper JSON response, but running it from a Debian server retrieves a 302 found.
At first I thought it could be because of the wget version differences, but running curl locally also works while wget doesn't work properly.
Is there anything that I should be setting up on my server to get a proper response? My guess is that the HTTPS connection is refusing my server from connecting properly.
So, this is a weird quirk of the Instagram servers. Nothing you can do about it.
The problem is that Instagram responds differently depending on whether you connect to their server over IPv4 or IPv6. Why they would do that is beyond me, but I can reliably reproduce the result by controlling for only this variable.
IPv4:
$ wget -O/dev/null -4 "https://www.instagram.com/instagram/?__a=1"
--2020-09-03 14:22:15-- https://www.instagram.com/instagram/?__a=1
Resolving www.instagram.com (www.instagram.com)... 157.240.27.174
Connecting to www.instagram.com (www.instagram.com)|157.240.27.174|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 118552 (116K) [application/json]
Saving to: ‘/dev/null’
100%[================================================================================================================================>] 118,552 306KB/s in 0.4s
2020-09-03 14:22:17 (306 KB/s) - ‘/dev/null’ saved [118552/118552]
IPv6:
$ wget -O/dev/null -6 "https://www.instagram.com/instagram/?__a=1"
--2020-09-03 14:22:54-- https://www.instagram.com/instagram/?__a=1
Resolving www.instagram.com (www.instagram.com)... 2a03:2880:f23f:e5:face:b00c:0:4420
Connecting to www.instagram.com (www.instagram.com)|2a03:2880:f23f:e5:face:b00c:0:4420|:443... connected.
HTTP request sent, awaiting response... 302 Found
Cookie coming from www.instagram.com attempted to set domain to www.instagram.com
Cookie coming from www.instagram.com attempted to set domain to www.instagram.com
Location: https://www.instagram.com/accounts/login/?next=/instagram/%3F__a%3D1 [following]
--2020-09-03 14:22:54-- https://www.instagram.com/accounts/login/?next=/instagram/%3F__a%3D1
Reusing existing connection to [www.instagram.com]:443.
HTTP request sent, awaiting response... 200 OK
Cookie coming from www.instagram.com attempted to set domain to www.instagram.com
Cookie coming from www.instagram.com attempted to set domain to www.instagram.com
Length: 48094 (47K) [text/html]
Saving to: ‘/dev/null’
100%[================================================================================================================================>] 48,094 --.-K/s in 0.04s
2020-09-03 14:22:54 (1.28 MB/s) - ‘/dev/null’ saved [48094/48094]
This is the same thing you see in your debug logs. On Manjaro, it makes a IPv4 connection, while on Debian it makes a IPv6 connection leading to the differences.
Welcome to the world of crazy webservers :)
In any case, the answer to your question then is to use only a IPv4 connection

Returns 503 service unavailable when uploading files to heroku

Apollo server setup in Heroku and tried to upload files using Altair but it returns 503 service unavailable.
But when uploading files in my local it uploads successfully so I dont know what am i missing.
This is my mutation :
mutation($img1: Upload, $img2: Upload){
uploadDocument(Image1: $img1, Image2: $img2, Type: 1){
Code
Message
}
}
The output is 503 service unavailable and this is what I get from the output of altair.
https://prnt.sc/p1z2c1

How to use wget with a proxy

I currently have been blocked from http://www.apkmirror.com, so a wget produces an ERROR 403: Forbidden:
kurt#kurt-ThinkPad:~$ wget http://www.apkmirror.com
--2017-04-21 12:51:42-- http://www.apkmirror.com/
Resolving www.apkmirror.com (www.apkmirror.com)... 104.19.135.58, 104.19.132.58, 104.19.133.58, ...
Connecting to www.apkmirror.com (www.apkmirror.com)|104.19.135.58|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2017-04-21 12:51:42 ERROR 403: Forbidden.
I'm trying to use a proxy from https://free-proxy-list.net/ to gain access. For example, following https://www.gnu.org/software/wget/manual/html_node/Proxies.html, I've tried
kurt#kurt-ThinkPad:~$ wget http://www.apkmirror.com#70.32.89.160:3128
--2017-04-21 12:57:56-- http://www.apkmirror.com#70.32.89.160:3128/
Connecting to 70.32.89.160:3128... connected.
HTTP request sent, awaiting response... 400 Bad Request
2017-04-21 12:57:59 ERROR 400: Bad Request.
but I get an ERROR 400: Bad Request. Is there anything wrong with this (attempted) usage of wget?
You are using the wrong method, Let me tell you.
Go to home on your server or computer using cd ~
then create a file using vim like vi ~/.wgetrc
and paste your proxy URL inside the file using as below.
use_proxy = on
http_proxy = http://70.32.89.160:3128
https_proxy = http://70.32.89.160:3128
ftp_proxy = http://70.32.89.160:3128
now use below command to access your blocked side.
wget -e use_proxy=yes -e http_proxy=$proxy http://www.apkmirror.com
or try using wget http://www.apkmirror.com you will see below output.
root#ubuntu:~# wget www.apkmirror.co
--2017-04-21 08:12:45-- http://www.apkmirror.co/
Connecting to 70.32.89.160:3128... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: http://www.apkmirror.co/ [following]
--2017-04-21 08:12:47-- http://www.apkmirror.co/
Connecting to 70.32.89.160:3128... connected.
Proxy request sent, awaiting response... 200 OK
Length: 76512 (75K) [text/html]
Saving to: ‘index.html.8’
100%[===================================================================================================================>] 76,512 447KB/s in 0.2s
2017-04-21 08:12:49 (447 KB/s) - ‘index.html.8’ saved [76512/76512]
you can use,this is:
wget -e use_proxy=yes -e http_proxy=http://ilanni:123456#10.10.10.128:3128 http://oss.aliyuncs.com/aliyunecs/rds_backup_extract.sh
start wget through socks5 proxy using tsocks:
install tsocks: sudo apt install tsocks
config tsocks
# vi /etc/tsocks.conf
server = 127.0.0.1
server_type = 5
server_port = 1080
start: tsocks wget http://url_to_get

How to read grpc command line tool error messages from the responses?

I am using the grpc command line tool to test response for my grpc request. This is the official link to the grpc command line tool: https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md (The usage guide is not updated. Kindly read ~/workspace/src/github.com/grpc/bins/opt/grpc_cli help)
I am running the command from the location where my protocol file resides. I am sending a request like this, (FYI: I am also sending the metadata. Irrespective of inclusion of the metadata or not I am getting the same error message) :
$ ~/my_workspace/src/github.com/grpc/bins/opt/grpc_cli call 0.0.0.0:50051 \
MyGrpcMethod <name_of_my_proto_file.proto> "abc : '12-34-56-78', xyz: '1234'" \
--metadata "auth:<auth_token>:space:xxx:org:xxx" --enable_ssl=false
In the response I am getting it says that there are some errors however, it does not show what the errors are. Here is the response I got from my client request:
connecting to 0.0.0.0:50051
Failed to read response.
Rpc failed with status code 12 error message unknown service my_agent.MyServiceAPI
Right now, I am not able to figure out from the documentation or otherwise on how to read the response. Did anyone face an issue like this?

wget recursive image download - error 404

I want to download all the png images in http://media.pldh.net/pokemon/go/ directory with wget. I am sure there are images in the directory: http://media.pldh.net/pokemon/go/bulbasaur.png
This is what i use:
wget -r -nd -np -A.png http://media.pldh.net/pokemon/go/
This is the output:
--2016-08-06 13:46:20-- http://media.pldh.net/pokemon/go/
Resolving media.pldh.net (media.pldh.net)... 192.185.70.249
Connecting to media.pldh.net (media.pldh.net)|192.185.70.249|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-08-06 13:46:21 ERROR 404: Not Found.
Is it possible use wget to download recursively all the images?

Resources