└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # metadata-one-liners 2 | 3 | Retrive metadata endpoint data with these one liners. 4 | 5 | Feel free to do a PR request if you want to add or alter anything. 6 | 7 | 8 | 9 | Python 2 10 | --- 11 | 12 | AWS 13 | 14 | ``` 15 | python -c 'import urllib2; print(urllib2.urlopen("http://169.254.169.254/latest/meta-data/").read())' 16 | ``` 17 | 18 | Digital Ocean 19 | 20 | ``` 21 | python -c 'import urllib2; print(urllib2.urlopen("http://169.254.169.254/metadata/v1/").read())' 22 | ``` 23 | 24 | Google 25 | 26 | ``` 27 | python -c 'import urllib2; print(urllib2.urlopen("http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json").read())' 28 | ``` 29 | 30 | Azure (not complete) need headers 31 | 32 | ``` 33 | python -c 'import urllib2; print(urllib2.urlopen("http://169.254.169.254/metadata/instance?api-version=2017-04-02").read())' 34 | ``` 35 | 36 | 37 | 38 | 39 | 40 | 41 | Python 3 42 | --- 43 | 44 | AWS 45 | 46 | ``` 47 | python3 -c 'import urllib.request; print(urllib.request.urlopen("http://169.254.169.254/latest/meta-data/").read())'' 48 | ``` 49 | 50 | Digital Ocean 51 | 52 | ``` 53 | python3 -c 'import urllib.request; print(urllib.request.urlopen("http://169.254.169.254/metadata/v1/").read())'' 54 | ``` 55 | 56 | Google 57 | 58 | ``` 59 | python3 -c 'import urllib.request; print(urllib.request.urlopen("http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json").read())'' 60 | ``` 61 | 62 | 63 | Azure (not complete) need headers 64 | 65 | ``` 66 | python3 -c 'import urllib.request; print(urllib.request.urlopen("http://169.254.169.254/metadata/instance?api-version=2017-04-02").read())'' 67 | ``` 68 | 69 | 70 | Wget 71 | --- 72 | 73 | 74 | AWS 75 | 76 | ``` 77 | wget -q -O - http://169.254.169.254/latest/meta-data/ 78 | ``` 79 | 80 | Digital Ocean 81 | 82 | ``` 83 | wget -q -O - http://169.254.169.254/metadata/v1/ 84 | ``` 85 | 86 | Google 87 | 88 | ``` 89 | wget http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json 90 | ``` 91 | 92 | Azure 93 | 94 | ``` 95 | wget --header="Metadata: true" http://169.254.169.254/metadata/instance?api-version=2017-04-02 96 | ``` 97 | 98 | 99 | 100 | 101 | 102 | 103 | Curl 104 | --- 105 | 106 | AWS 107 | 108 | ``` 109 | curl http://169.254.169.254/latest/meta-data/ 110 | curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/$(curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/)/owner-id/ 111 | curl http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key 112 | curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ 113 | curl http://169.254.169.254/latest/meta-data/iam/security-credentials/$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/) 114 | curl http://169.254.169.254/latest/dynamic/instance-identity/document/ 115 | curl http://169.254.169.254/latest/meta-data/security-groups/ 116 | curl http://169.254.169.254/latest/user-data 117 | ``` 118 | 119 | Digital Ocean 120 | 121 | ``` 122 | curl http://169.254.169.254/metadata/v1/ 123 | ``` 124 | 125 | Google 126 | 127 | ``` 128 | curl http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json 129 | curl http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/sshKeys 130 | curl http://metadata.google.internal/computeMetadata/v1beta1/instance/attributes/kube-env 131 | curl http://metadata.google.internal/computeMetadata/v1beta1/instance/service-accounts/default/identity 132 | curl http://metadata.google.internal/computeMetadata/v1beta1/instance/hostname 133 | curl http://metadata.google.internal/computeMetadata/v1beta1/instance/attributes/?recursive=true&alt=json 134 | 135 | curl http://metadata.google.internal/computeMetadata/v1/project/attributes/ssh-keys?alt=json -H "Metadata-Flavor: Google" 136 | curl http://metadata.google.internal/computeMetadata/v1/project/attributes/sshKeys -H "Metadata-Flavor: Google" 137 | curl http://metadata.google.internal/computeMetadata/v1/instance/attributes/kube-env -H "Metadata-Flavor: Google" 138 | curl http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/identity -H "Metadata-Flavor: Google" 139 | curl http://metadata.google.internal/computeMetadata/v1/instance/hostname -H "Metadata-Flavor: Google" 140 | curl http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=true&alt=json -H "Metadata-Flavor: Google" 141 | 142 | 143 | ``` 144 | 145 | Azure 146 | 147 | ``` 148 | curl -H Metadata:true http://169.254.169.254/metadata/instance?api-version=2019-08-15 149 | curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2019-08-15&resource=https%3A%2F%2Fmanagement.azure.com%2F' -H Metadata:true -s 150 | ``` 151 | 152 | 153 | 154 | Busybox 155 | --- 156 | 157 | AWS 158 | 159 | ``` 160 | busybox wget -q -O - http://169.254.169.254/latest/meta-data/ 161 | busybox wget -q -O - http://169.254.169.254/latest/meta-data/network/interfaces/macs/$(busybox wget -q -O - http://169.254.169.254/latest/meta-data/network/interfaces/macs/)/owner-id/ 162 | busybox wget -q -O - http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key 163 | busybox wget -q -O - http://169.254.169.254/latest/meta-data/iam/security-credentials/ 164 | busybox wget -q -O - http://169.254.169.254/latest/meta-data/iam/security-credentials/$(busybox wget -q -O - http://169.254.169.254/latest/meta-data/iam/security-credentials/) 165 | busybox wget -q -O - http://169.254.169.254/latest/dynamic/instance-identity/document/ 166 | busybox wget -q -O - http://169.254.169.254/latest/meta-data/security-groups/ 167 | busybox wget -q -O - http://169.254.169.254/latest/user-data 168 | ``` 169 | 170 | Digital Ocean 171 | 172 | ``` 173 | busybox wget -q -O - http://169.254.169.254/metadata/v1/ 174 | ``` 175 | 176 | Google 177 | 178 | ``` 179 | busybox wget -q -O - http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json 180 | busybox wget -q -O - http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/sshKeys 181 | busybox wget -q -O - http://metadata.google.internal/computeMetadata/v1beta1/instance/attributes/kube-env 182 | busybox wget -q -O - http://metadata.google.internal/computeMetadata/v1beta1/instance/service-accounts/default/identity 183 | busybox wget -q -O - http://metadata.google.internal/computeMetadata/v1beta1/instance/hostname 184 | ``` 185 | 186 | Azure 187 | 188 | ``` 189 | busybox wget --header="Metadata: true" http://169.254.169.254/metadata/instance?api-version=2017-04-02 190 | 191 | ``` 192 | 193 | Powershell 194 | --- 195 | 196 | ``` 197 | powershell.exe -Command "invoke-webrequest http://169.254.169.254/latest/meta-data/iam/security-credentials/ | Select-Object -Expand Content" 198 | ``` 199 | 200 | ``` 201 | powershell.exe -Command "invoke-webrequest http://metadata.google.internal/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json | Select-Object -Expand Content" 202 | ``` 203 | 204 | 205 | 206 | 207 | 208 | 209 | NC 210 | --- 211 | 212 | AWS 213 | 214 | ``` 215 | echo -e "GET /latest/meta-data/ HTTP/1.0\r\n\r\n" | nc 169.254.169.254 80 216 | ``` 217 | 218 | Digital Ocean 219 | 220 | ``` 221 | echo -e "GET /metadata/v1/ HTTP/1.0\r\n\r\n" | nc 169.254.169.254 80 222 | ``` 223 | 224 | Google 225 | 226 | ``` 227 | TBC 228 | ``` 229 | 230 | Azure 231 | 232 | ``` 233 | TBC 234 | ``` 235 | 236 | ### Oracle Cloud 237 | ``` 238 | http://169.254.169.254/opc/v1/instance/ 239 | http://169.254.169.254/opc/v1/instance/metadata/ (gets public sshkey) 240 | http://169.254.169.254/opc/v1/instance/shape 241 | http://169.254.169.254/opc/v1/identity/cert.pem 242 | http://169.254.169.254/opc/v1/identity/key.pem 243 | http://169.254.169.254/opc/v1/identity/intermediate.pem 244 | ``` 245 | 246 | ### Alibaba 247 | ``` 248 | http://100.100.100.200/latest/meta-data/ 249 | http://100.100.100.200/latest/meta-data/instance-id 250 | http://100.100.100.200/latest/meta-data/image-id 251 | ``` 252 | 253 | 254 | # Rethink DB 255 | 256 | ### Google 257 | ``` 258 | r.http('http://metadata.google.internal/computeMetadata/v1/project/attributes/ssh-keys?alt=json',{ header: { 'Metadata-Flavor': 'Google' } }) 259 | ``` 260 | --------------------------------------------------------------------------------