@@ -18,7 +18,7 @@ select the correct creation rule.
1818
1919The simplest way to decrypt data from stdin is as follows:
2020
21- ``` sh
21+ ``` console
2222$ cat encrypted-data | sops decrypt > decrypted-data
2323```
2424
@@ -31,7 +31,7 @@ To avoid this, you can either provide a filename with `--filename-override`,
3131or explicitly control the input and output formats by passing
3232` --input-type ` and ` --output-type ` as appropriate:
3333
34- ``` sh
34+ ``` console
3535$ cat encrypted-data | sops decrypt --filename-override filename.yaml > decrypted-data
3636$ cat encrypted-data | sops decrypt --input-type yaml --output-type yaml > decrypted-data
3737```
@@ -45,7 +45,7 @@ look up the correct creation rule from `.sops.yaml`. Therefore, you must
4545provide the ` --filename-override ` parameter which allows you to tell
4646SOPS which filename to use to match creation rules:
4747
48- ``` sh
48+ ``` console
4949$ echo ' foo: bar' | sops encrypt --filename-override path/filename.sops.yaml > encrypted-data
5050```
5151
@@ -55,7 +55,7 @@ filename will also be used to determine the input and output store. As
5555always, the input store type can be adjusted by passing ` --input-type ` ,
5656and the output store type by passing ` --output-type ` :
5757
58- ``` sh
58+ ``` console
5959$ echo foo=bar | sops encrypt --filename-override path/filename.sops.yaml --input-type dotenv > encrypted-data
6060```
6161
@@ -115,27 +115,27 @@ respectively. For example, if a program looks for credentials in its
115115environment, `exec-env` can be used to ensure that the decrypted
116116contents are available only to this process and never written to disk.
117117
118- ` ` ` sh
119- # print secrets to stdout to confirm values
118+ ` ` ` console
119+ $ # print secrets to stdout to confirm values
120120$ sops decrypt out.json
121121{
122122 "database_password": "jf48t9wfw094gf4nhdf023r",
123123 "AWS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
124124 "AWS_SECRET_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
125125}
126126
127- # decrypt out.json and run a command
128- # the command prints the environment variable and runs a script that uses it
127+ $ # decrypt out.json and run a command
128+ $ # the command prints the environment variable and runs a script that uses it
129129$ sops exec-env out.json 'echo secret: $database_password; ./database-import'
130130secret: jf48t9wfw094gf4nhdf023r
131131
132- # launch a shell with the secrets available in its environment
132+ $ # launch a shell with the secrets available in its environment
133133$ sops exec-env out.json 'sh'
134- sh-3.2# echo $database_password
134+ $ echo $database_password
135135jf48t9wfw094gf4nhdf023r
136136
137- # the secret is not accessible anywhere else
138- sh-3.2 $ exit
137+ $ # the secret is not accessible anywhere else
138+ $ exit
139139$ echo your password: $database_password
140140your password:
141141` ` `
@@ -154,31 +154,31 @@ the process is finished executing. `exec-file` behaves similar to
154154will be substituted with the temporary file path (whether a FIFO or an
155155actual file).
156156
157- ` ` ` sh
158- # operating on the same file as before, but as a file this time
159- $ sops exec-file out.json 'echo your temporary file: {}; cat {}'
157+ ` ` ` console
158+ % # operating on the same file as before, but as a file this time
159+ % sops exec-file out.json 'echo your temporary file: {}; cat {}'
160160your temporary file: /tmp/.sops894650499/tmp-file
161161{
162162 "database_password": "jf48t9wfw094gf4nhdf023r",
163163 "AWS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
164164 "AWS_SECRET_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
165165}
166166
167- # launch a shell with a variable TMPFILE pointing to the temporary file
168- $ sops exec-file --no-fifo out.json 'TMPFILE={} sh'
169- sh-3.2 $ echo $TMPFILE
167+ % # launch a shell with a variable TMPFILE pointing to the temporary file
168+ % sops exec-file --no-fifo out.json 'TMPFILE={} sh'
169+ $ echo $TMPFILE
170170/tmp/.sops506055069/tmp-file291138648
171- sh-3.2 $ cat $TMPFILE
171+ $ cat $TMPFILE
172172{
173173 "database_password": "jf48t9wfw094gf4nhdf023r",
174174 "AWS_ACCESS_KEY_ID": "AKIAIOSFODNN7EXAMPLE",
175175 "AWS_SECRET_KEY": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
176176}
177- sh-3.2 $ ./program --config $TMPFILE
178- sh-3.2 $ exit
177+ $ ./program --config $TMPFILE
178+ $ exit
179179
180- # try to open the temporary file from earlier
181- $ cat /tmp/.sops506055069/tmp-file291138648
180+ % # try to open the temporary file from earlier
181+ % cat /tmp/.sops506055069/tmp-file291138648
182182cat: /tmp/.sops506055069/tmp-file291138648: No such file or directory
183183` ` `
184184
@@ -192,20 +192,20 @@ possible for added security.
192192To overwrite the default file name (`tmp-file`) in `exec-file` use the
193193` --filename <filename>` parameter.
194194
195- ` ` ` sh
196- # the encrypted file can't be read by the current user
197- $ cat out.json
195+ ` ` ` console
196+ % # the encrypted file can't be read by the current user
197+ % cat out.json
198198cat: out.json: Permission denied
199199
200- # execute sops as root, decrypt secrets, then drop privileges
201- $ sudo sops exec-env --user nobody out.json 'sh'
202- sh-3.2 $ echo $database_password
200+ % # execute sops as root, decrypt secrets, then drop privileges
201+ % sudo sops exec-env --user nobody out.json 'sh'
202+ $ echo $database_password
203203jf48t9wfw094gf4nhdf023r
204204
205- # dropped privileges, still can't load the original file
206- sh-3.2 $ id
205+ $ # dropped privileges, still can't load the original file
206+ $ id
207207uid=4294967294(nobody) gid=4294967294(nobody) groups=4294967294(nobody)
208- sh-3.2 $ cat out.json
208+ $ cat out.json
209209cat: out.json: Permission denied
210210` ` `
211211
@@ -248,13 +248,13 @@ For example, to decrypt a file using both the local key service and the
248248key service exposed on the unix socket located in `/tmp/sops.sock`, you
249249can run :
250250
251- ` ` ` sh
251+ ` ` ` console
252252$ sops decrypt --keyservice unix:///tmp/sops.sock file.yaml
253253` ` `
254254
255255And if you only want to use the key service exposed on the unix socket
256256located in `/tmp/sops.sock` and not the local key service, you can run :
257257
258- ` ` ` sh
258+ ` ` ` console
259259$ sops decrypt --enable-local-keyservice=false --keyservice unix:///tmp/sops.sock file.yaml
260260` ` `
0 commit comments