In this post, I will demonstrate how to use the Ubuntu Pastebin utility with cURL to make pastes from the command line. You can download it from here

×
-
+
Konsole

curl -fsSL -X POST \
--url https://paste.ubuntu.com \
--output /dev/null \
--write-out "%{url_effective}\n" \
--data-urlencode "content@${PASTEBIN_CONTENT:-/dev/stdin}" \
--data "poster=${PASTEBIN_POSTER:-`whoami`@`hostname`}" \
--data "expiration=${PASTEBIN_EXPIRATION:-day}" \
--data "syntax=${PASTEBIN_SYNTAX:-text}"


By default, the pastes expire in one day. The Ubuntu pastebin utility is quite limited and offers no method for retracting a paste, so for safety, it's best to set an expiry. The options are day, week, month, year

To make the pastes permanent by default, set the expiration field as empty, i.e --data "expiration="

To test it works, I will use it to upload itself on pastebin.ubuntu.com

×
-
+
Konsole

[rohan@desktop]$ ./pastebin.sh < pastebin.sh
https://paste.ubuntu.com/p/Wjz5HnbjJt/
[rohan@desktop]$