CURL request using .netrc file
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I am trying to write a script which is saving the credentials to a .netrc file and then it is reading from the file in order to pass them to a curl command and saves the returned cookie file for future use. I am interested if this is secure way to pass the username and password and if there is a man in the middle attack would they be able to sniff the credentials if the server which I am trying to reach is over HTTP.
#!/bin/bash
IP="192.168.0.1"
user="Administrator"
pass="Password1234"
function credentials
mkdir "$HOME"/.netrc
rm "$HOME"/.netrc/credentials.txt
touch "$HOME"/.netrc/credentials.txt
echo "machine $IP"; echo "login $user"; echo "password $pass"; >> "$HOME"/.netrc/credentials.txt
chmod 600 "$HOME"/.netrc/credentials.txt
function cookie
curl -v -c cookie.txt -n "$HOME"/.netrc/credentials.txt http://"$IP"/setup.php
credentials
cookie
I have checked and the credentials.txt file is properly saved in the corresponding directory and the credentials have the right permissions, but when I try to run the cookie function, I got the following error: Couldn't find host 192.168.0.1 in the .netrc file; using defaults
. Why curl is not able to fetch the configured username and password from the credentials.txt file?
bash shell-script security curl .netrc
add a comment |Â
up vote
0
down vote
favorite
I am trying to write a script which is saving the credentials to a .netrc file and then it is reading from the file in order to pass them to a curl command and saves the returned cookie file for future use. I am interested if this is secure way to pass the username and password and if there is a man in the middle attack would they be able to sniff the credentials if the server which I am trying to reach is over HTTP.
#!/bin/bash
IP="192.168.0.1"
user="Administrator"
pass="Password1234"
function credentials
mkdir "$HOME"/.netrc
rm "$HOME"/.netrc/credentials.txt
touch "$HOME"/.netrc/credentials.txt
echo "machine $IP"; echo "login $user"; echo "password $pass"; >> "$HOME"/.netrc/credentials.txt
chmod 600 "$HOME"/.netrc/credentials.txt
function cookie
curl -v -c cookie.txt -n "$HOME"/.netrc/credentials.txt http://"$IP"/setup.php
credentials
cookie
I have checked and the credentials.txt file is properly saved in the corresponding directory and the credentials have the right permissions, but when I try to run the cookie function, I got the following error: Couldn't find host 192.168.0.1 in the .netrc file; using defaults
. Why curl is not able to fetch the configured username and password from the credentials.txt file?
bash shell-script security curl .netrc
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to write a script which is saving the credentials to a .netrc file and then it is reading from the file in order to pass them to a curl command and saves the returned cookie file for future use. I am interested if this is secure way to pass the username and password and if there is a man in the middle attack would they be able to sniff the credentials if the server which I am trying to reach is over HTTP.
#!/bin/bash
IP="192.168.0.1"
user="Administrator"
pass="Password1234"
function credentials
mkdir "$HOME"/.netrc
rm "$HOME"/.netrc/credentials.txt
touch "$HOME"/.netrc/credentials.txt
echo "machine $IP"; echo "login $user"; echo "password $pass"; >> "$HOME"/.netrc/credentials.txt
chmod 600 "$HOME"/.netrc/credentials.txt
function cookie
curl -v -c cookie.txt -n "$HOME"/.netrc/credentials.txt http://"$IP"/setup.php
credentials
cookie
I have checked and the credentials.txt file is properly saved in the corresponding directory and the credentials have the right permissions, but when I try to run the cookie function, I got the following error: Couldn't find host 192.168.0.1 in the .netrc file; using defaults
. Why curl is not able to fetch the configured username and password from the credentials.txt file?
bash shell-script security curl .netrc
I am trying to write a script which is saving the credentials to a .netrc file and then it is reading from the file in order to pass them to a curl command and saves the returned cookie file for future use. I am interested if this is secure way to pass the username and password and if there is a man in the middle attack would they be able to sniff the credentials if the server which I am trying to reach is over HTTP.
#!/bin/bash
IP="192.168.0.1"
user="Administrator"
pass="Password1234"
function credentials
mkdir "$HOME"/.netrc
rm "$HOME"/.netrc/credentials.txt
touch "$HOME"/.netrc/credentials.txt
echo "machine $IP"; echo "login $user"; echo "password $pass"; >> "$HOME"/.netrc/credentials.txt
chmod 600 "$HOME"/.netrc/credentials.txt
function cookie
curl -v -c cookie.txt -n "$HOME"/.netrc/credentials.txt http://"$IP"/setup.php
credentials
cookie
I have checked and the credentials.txt file is properly saved in the corresponding directory and the credentials have the right permissions, but when I try to run the cookie function, I got the following error: Couldn't find host 192.168.0.1 in the .netrc file; using defaults
. Why curl is not able to fetch the configured username and password from the credentials.txt file?
bash shell-script security curl .netrc
edited Mar 5 at 13:37
Drakonoved
674518
674518
asked Mar 5 at 13:14
Georgõ Stoyanov
16515
16515
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
As I understand the man page (of curl), the option -n
just enable looking for a .netrc
file, but it does not expect the file path of this file. This is the option --netrc-file
. From the man-page:
--netrc-file
This option is similar to --netrc, except that you provide the
path (absolute or relative) to the netrc file that Curl should use.
You can only specify one netrc file per invocation. If several
--netrc-file options are provided, only the last one will be used.
(Added in 7.21.5)
This option overrides any use of --netrc as they are mutually
exclusive. It will also abide by --netrc-optional if specified.
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
As I understand the man page (of curl), the option -n
just enable looking for a .netrc
file, but it does not expect the file path of this file. This is the option --netrc-file
. From the man-page:
--netrc-file
This option is similar to --netrc, except that you provide the
path (absolute or relative) to the netrc file that Curl should use.
You can only specify one netrc file per invocation. If several
--netrc-file options are provided, only the last one will be used.
(Added in 7.21.5)
This option overrides any use of --netrc as they are mutually
exclusive. It will also abide by --netrc-optional if specified.
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
add a comment |Â
up vote
2
down vote
accepted
As I understand the man page (of curl), the option -n
just enable looking for a .netrc
file, but it does not expect the file path of this file. This is the option --netrc-file
. From the man-page:
--netrc-file
This option is similar to --netrc, except that you provide the
path (absolute or relative) to the netrc file that Curl should use.
You can only specify one netrc file per invocation. If several
--netrc-file options are provided, only the last one will be used.
(Added in 7.21.5)
This option overrides any use of --netrc as they are mutually
exclusive. It will also abide by --netrc-optional if specified.
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
As I understand the man page (of curl), the option -n
just enable looking for a .netrc
file, but it does not expect the file path of this file. This is the option --netrc-file
. From the man-page:
--netrc-file
This option is similar to --netrc, except that you provide the
path (absolute or relative) to the netrc file that Curl should use.
You can only specify one netrc file per invocation. If several
--netrc-file options are provided, only the last one will be used.
(Added in 7.21.5)
This option overrides any use of --netrc as they are mutually
exclusive. It will also abide by --netrc-optional if specified.
As I understand the man page (of curl), the option -n
just enable looking for a .netrc
file, but it does not expect the file path of this file. This is the option --netrc-file
. From the man-page:
--netrc-file
This option is similar to --netrc, except that you provide the
path (absolute or relative) to the netrc file that Curl should use.
You can only specify one netrc file per invocation. If several
--netrc-file options are provided, only the last one will be used.
(Added in 7.21.5)
This option overrides any use of --netrc as they are mutually
exclusive. It will also abide by --netrc-optional if specified.
answered Mar 5 at 13:55
Alex338207
2791
2791
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
add a comment |Â
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
yes, this seems to be the problem, I was thinking that -n and --netrc-file are the same like --verbose and -v but apparently they are not. Thanks for the hint!
â Georgõ Stoyanov
Mar 5 at 14:07
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%2f428260%2fcurl-request-using-netrc-file%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