Why can't I authenticate a curl request when piping to less or more?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
(CentOS 7)
When I try a curl command like curl -u elastic -X GET 'http://localhost:9200/*' | more, I find that after typing only a single letter, the command executes as if I have pressed enter, and fails to authenticate.
Is this normal?
I can redirect to a file, or just scroll up, maybe even use wget (haven't tried), or even put my password in the command, but I would like to know what's going on here.
curl pipe
migrated from serverfault.com Oct 1 '17 at 22:09
This question came from our site for system and network administrators.
add a comment |Â
up vote
0
down vote
favorite
(CentOS 7)
When I try a curl command like curl -u elastic -X GET 'http://localhost:9200/*' | more, I find that after typing only a single letter, the command executes as if I have pressed enter, and fails to authenticate.
Is this normal?
I can redirect to a file, or just scroll up, maybe even use wget (haven't tried), or even put my password in the command, but I would like to know what's going on here.
curl pipe
migrated from serverfault.com Oct 1 '17 at 22:09
This question came from our site for system and network administrators.
Have you tried it without|more?
â Marco
Sep 29 '17 at 17:02
yes, it works fine without piping, and both withheadortail. It does not work withmoreorless.
â spanishgum
Sep 29 '17 at 19:09
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
(CentOS 7)
When I try a curl command like curl -u elastic -X GET 'http://localhost:9200/*' | more, I find that after typing only a single letter, the command executes as if I have pressed enter, and fails to authenticate.
Is this normal?
I can redirect to a file, or just scroll up, maybe even use wget (haven't tried), or even put my password in the command, but I would like to know what's going on here.
curl pipe
(CentOS 7)
When I try a curl command like curl -u elastic -X GET 'http://localhost:9200/*' | more, I find that after typing only a single letter, the command executes as if I have pressed enter, and fails to authenticate.
Is this normal?
I can redirect to a file, or just scroll up, maybe even use wget (haven't tried), or even put my password in the command, but I would like to know what's going on here.
curl pipe
curl pipe
asked Sep 26 '17 at 21:19
spanishgum
1437
1437
migrated from serverfault.com Oct 1 '17 at 22:09
This question came from our site for system and network administrators.
migrated from serverfault.com Oct 1 '17 at 22:09
This question came from our site for system and network administrators.
Have you tried it without|more?
â Marco
Sep 29 '17 at 17:02
yes, it works fine without piping, and both withheadortail. It does not work withmoreorless.
â spanishgum
Sep 29 '17 at 19:09
add a comment |Â
Have you tried it without|more?
â Marco
Sep 29 '17 at 17:02
yes, it works fine without piping, and both withheadortail. It does not work withmoreorless.
â spanishgum
Sep 29 '17 at 19:09
Have you tried it without
|more ?â Marco
Sep 29 '17 at 17:02
Have you tried it without
|more ?â Marco
Sep 29 '17 at 17:02
yes, it works fine without piping, and both with
head or tail. It does not work with more or less.â spanishgum
Sep 29 '17 at 19:09
yes, it works fine without piping, and both with
head or tail. It does not work with more or less.â spanishgum
Sep 29 '17 at 19:09
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
The problem is that curl and more are both reading from the same TTY at the same time. Moreover they are probably both changing the TTY settings; curl because the password you type shouldn't be shown on the screen. And more because it needs character based input rather than the default line based input.
To prevent that from happening I think you just need to delay starting the more command until the curl command has started producing output. I don't know of a standard command to do that, but it can be done with two lines of Python code.
#!/usr/bin/python
import select
select.select([0], , )
With the above Python script you can then try this variation of the original command:
curl -u elastic -X GET 'http://localhost:9200/*' | ( ./wait.py ; more )
1
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
add a comment |Â
up vote
0
down vote
per
# curl --help | grep -- ' -u'
-u, --user USER[:PASSWORD] Server user and password
#
try:
curl --silent --user elastic:changeme --request GET localhost:9200/*?pretty | more
yet another solution:
# pass=changeme
# curl -I -u alexus:$pass https://X.X.X
HTTP/1.1 200 OK
Server: nginx/1.13.5
Date: Wed, 27 Sep 2017 17:27:19 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2350
Connection: keep-alive
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Last-Modified: Sun, 13 Aug 2017 18:21:51 GMT
Strict-Transport-Security: max-age=15768000
#
one can also store pass variable inside of a file (don't forget to chmod 700 that file) and use source to read variable before running curl.
voila!
1
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
The problem is that curl and more are both reading from the same TTY at the same time. Moreover they are probably both changing the TTY settings; curl because the password you type shouldn't be shown on the screen. And more because it needs character based input rather than the default line based input.
To prevent that from happening I think you just need to delay starting the more command until the curl command has started producing output. I don't know of a standard command to do that, but it can be done with two lines of Python code.
#!/usr/bin/python
import select
select.select([0], , )
With the above Python script you can then try this variation of the original command:
curl -u elastic -X GET 'http://localhost:9200/*' | ( ./wait.py ; more )
1
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
add a comment |Â
up vote
3
down vote
accepted
The problem is that curl and more are both reading from the same TTY at the same time. Moreover they are probably both changing the TTY settings; curl because the password you type shouldn't be shown on the screen. And more because it needs character based input rather than the default line based input.
To prevent that from happening I think you just need to delay starting the more command until the curl command has started producing output. I don't know of a standard command to do that, but it can be done with two lines of Python code.
#!/usr/bin/python
import select
select.select([0], , )
With the above Python script you can then try this variation of the original command:
curl -u elastic -X GET 'http://localhost:9200/*' | ( ./wait.py ; more )
1
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
The problem is that curl and more are both reading from the same TTY at the same time. Moreover they are probably both changing the TTY settings; curl because the password you type shouldn't be shown on the screen. And more because it needs character based input rather than the default line based input.
To prevent that from happening I think you just need to delay starting the more command until the curl command has started producing output. I don't know of a standard command to do that, but it can be done with two lines of Python code.
#!/usr/bin/python
import select
select.select([0], , )
With the above Python script you can then try this variation of the original command:
curl -u elastic -X GET 'http://localhost:9200/*' | ( ./wait.py ; more )
The problem is that curl and more are both reading from the same TTY at the same time. Moreover they are probably both changing the TTY settings; curl because the password you type shouldn't be shown on the screen. And more because it needs character based input rather than the default line based input.
To prevent that from happening I think you just need to delay starting the more command until the curl command has started producing output. I don't know of a standard command to do that, but it can be done with two lines of Python code.
#!/usr/bin/python
import select
select.select([0], , )
With the above Python script you can then try this variation of the original command:
curl -u elastic -X GET 'http://localhost:9200/*' | ( ./wait.py ; more )
answered Oct 1 '17 at 22:17
kasperd
2,1691925
2,1691925
1
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
add a comment |Â
1
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
1
1
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
curl -u .... | sleep 20 ; less ; would give you 20 seconds to type the password before less started to read the terminal.
â icarus
Oct 2 '17 at 0:34
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
This is exactly what I was looking for! This makes sense. Thank you both!
â spanishgum
Oct 2 '17 at 16:03
add a comment |Â
up vote
0
down vote
per
# curl --help | grep -- ' -u'
-u, --user USER[:PASSWORD] Server user and password
#
try:
curl --silent --user elastic:changeme --request GET localhost:9200/*?pretty | more
yet another solution:
# pass=changeme
# curl -I -u alexus:$pass https://X.X.X
HTTP/1.1 200 OK
Server: nginx/1.13.5
Date: Wed, 27 Sep 2017 17:27:19 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2350
Connection: keep-alive
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Last-Modified: Sun, 13 Aug 2017 18:21:51 GMT
Strict-Transport-Security: max-age=15768000
#
one can also store pass variable inside of a file (don't forget to chmod 700 that file) and use source to read variable before running curl.
voila!
1
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
add a comment |Â
up vote
0
down vote
per
# curl --help | grep -- ' -u'
-u, --user USER[:PASSWORD] Server user and password
#
try:
curl --silent --user elastic:changeme --request GET localhost:9200/*?pretty | more
yet another solution:
# pass=changeme
# curl -I -u alexus:$pass https://X.X.X
HTTP/1.1 200 OK
Server: nginx/1.13.5
Date: Wed, 27 Sep 2017 17:27:19 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2350
Connection: keep-alive
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Last-Modified: Sun, 13 Aug 2017 18:21:51 GMT
Strict-Transport-Security: max-age=15768000
#
one can also store pass variable inside of a file (don't forget to chmod 700 that file) and use source to read variable before running curl.
voila!
1
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
add a comment |Â
up vote
0
down vote
up vote
0
down vote
per
# curl --help | grep -- ' -u'
-u, --user USER[:PASSWORD] Server user and password
#
try:
curl --silent --user elastic:changeme --request GET localhost:9200/*?pretty | more
yet another solution:
# pass=changeme
# curl -I -u alexus:$pass https://X.X.X
HTTP/1.1 200 OK
Server: nginx/1.13.5
Date: Wed, 27 Sep 2017 17:27:19 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2350
Connection: keep-alive
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Last-Modified: Sun, 13 Aug 2017 18:21:51 GMT
Strict-Transport-Security: max-age=15768000
#
one can also store pass variable inside of a file (don't forget to chmod 700 that file) and use source to read variable before running curl.
voila!
per
# curl --help | grep -- ' -u'
-u, --user USER[:PASSWORD] Server user and password
#
try:
curl --silent --user elastic:changeme --request GET localhost:9200/*?pretty | more
yet another solution:
# pass=changeme
# curl -I -u alexus:$pass https://X.X.X
HTTP/1.1 200 OK
Server: nginx/1.13.5
Date: Wed, 27 Sep 2017 17:27:19 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 2350
Connection: keep-alive
Accept-Ranges: bytes
Cache-Control: max-age=31536000
Last-Modified: Sun, 13 Aug 2017 18:21:51 GMT
Strict-Transport-Security: max-age=15768000
#
one can also store pass variable inside of a file (don't forget to chmod 700 that file) and use source to read variable before running curl.
voila!
answered Sep 26 '17 at 21:48
alexus
443620
443620
1
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
add a comment |Â
1
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
1
1
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
"or even put my password in the command, but I would like to know what's going on here" -- I think OP knows that's an option, but would prefer not to do this.
â Aaron Copley
Sep 26 '17 at 21:59
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
Indeed. I don't want to see my password saved into my history (especially when I jump into root). I saw a gpgkey technique that could avoid this, but I still want to know why this happens out of curiosity.
â spanishgum
Sep 27 '17 at 15:12
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
@spanishgum take a look at my updated answer for alternative ways to not to save password in a history.
â alexus
Sep 27 '17 at 17:31
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395525%2fwhy-cant-i-authenticate-a-curl-request-when-piping-to-less-or-more%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Have you tried it without
|more?â Marco
Sep 29 '17 at 17:02
yes, it works fine without piping, and both with
headortail. It does not work withmoreorless.â spanishgum
Sep 29 '17 at 19:09