Passing credentials via .netric file in Linux


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Passing credentials via .netric file in Linux
# 1  
Old 12-25-2015
Passing credentials via .netric file in Linux

How to create netrc file...I searched in google & got to know that we have to create .netrc file in home directory, I've created .netrc file in in home directory
created .netrc file in home directory
Code:
more .netrc 
machine $HOSTNAME login xxxx password xxxxx

Note: echo $HOSTNAME
apachetomcat@dellsys.com

Last edited by sam@sam; 12-26-2015 at 01:40 AM..
# 2  
Old 12-25-2015
The two things to check with the use of .netrc are the syntax of the file content and the access rights of the file itself.

Here is an excerpt from some documentation I wrote several years ago but nothing has changed:

*****

The contents of the /.netrc file would, for example, be:-

machine plymsql login administrator password memorandum

NOTE: .netrc must have read/write access for the owner ONLY. If other users have read access it may fail to work and ftp will not auto-connect. Therefore, since in this case the user is root, should the file be re-created it must be set as follows:-
cd / <or cd to the home directory of the user under which the job is running>
chown <userid> .netrc
chmod 600 .netrc <giving read/write to only the owner (userid)>

If ftp finds the target nodename listed it uses the login name and password given to create an ftp connection to the target. Of course, this userid/password combination MUST give the process sufficient credentials and access rights to allow the reading/writing required to complete the required tasks. If the system manager changes the respective user account or password without reflecting this in /.netrc it will cause the whole ftp phase of the scripts to fail.

*****

Check these out and report back your progress, or lack of.

You can check out the .netrc functionality interactively by just entering "ftp <nodename>" at the command line. The ftp session should connect immediately without entering credentials. If it doesn't the .netrc mechanism isn't working. Ensure that the nodename can be resolved, eg. by an entry in /etc/hosts or other means such as DNS.

Last edited by hicksd8; 12-25-2015 at 05:11 AM..
# 3  
Old 12-25-2015
Thanks

Last edited by sam@sam; 12-26-2015 at 01:40 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check via SSH and credentials if file on remote server exists?

Hi there, I am sorry to ask that kind of beginner thing, but all the code I found online didnt work for me. All I want to do is: Check via SSH if a File exists on my webserver. The SSH login has to be with username and password. So I would be very thankful if somebody could write the line.... (8 Replies)
Discussion started by: Jens885544
8 Replies

2. UNIX for Beginners Questions & Answers

Passing User Credentials with Mount Command

My HP-UX server currently mounts a directory on a Windows 2012 server. The Windows server allows anonymous connections for RW and this configuration has worked well for years. Now, due to tightening security requirements I can't use anonymous. I also can't setup Identity Mapping on the Windows... (5 Replies)
Discussion started by: jduehmig
5 Replies

3. AIX

Passing user/pass credentials to automountd map file.

How could I pass credentials to the automountd daemon through it's map files? Tried credentials=/some/file.txt - Didn't work. Tried SHARE.domain.com/user/pass/SHARE_NAME in map file - Didn't work Tried user=USER,pass=PASS - Didn't work. I can see the mounts created but when I access them... (4 Replies)
Discussion started by: Devyn
4 Replies

4. UNIX for Advanced & Expert Users

Need to pass credentials in one Go

Hi, We usually switch user using the below command. sudo su - user1 It then prompts for the password which we feed in. I wish to pass both the username and the password in one go thus eliminating the prompt for the password. I am using java standalone to connect to unix using... (11 Replies)
Discussion started by: mohtashims
11 Replies

5. Emergency UNIX and Linux Support

Linux: passing parameters to kernel modules

Hi, I need to set qlogic qla2xxx parameters in /etc/modprobe.conf (Oracle Linux Server release 5.7, almost equal to RedHat 5.7) two questions: how can I pass this parameters to the module while it is loaded (fibre channel luns are in use), if possible at all and how can I check the... (3 Replies)
Discussion started by: funksen
3 Replies

6. Shell Programming and Scripting

FTP credentials from a config file

Hi, I am using the following syntax to connect to an FTP server and paste the file. Based on the value in the variable $Folder, i want to connect to different folders on the same server. The credential is different to access different folders. How to get the user name and password from a... (3 Replies)
Discussion started by: ashok.k
3 Replies

7. Shell Programming and Scripting

Issues using array credentials to read contents of a file

Hi, I am trying to read the contents of a file using array credentials in unix. The file I am trying to read is tab separated and contains the below contents. # partnerid Direc Server Port Source_Dir Target_Dir Mask Remove Files Passwordless Compare Files ... (3 Replies)
Discussion started by: aartikara
3 Replies

8. Shell Programming and Scripting

Hide DB Credentials in unix

Hi, I my unix we have one file that contains all the database credentials. we are calling that file while connecting databse. I need to hide that file....other user should not view that file. How to do this. Please suggest me apart from permisstion(chmod) level suggestion. Regards,... (3 Replies)
Discussion started by: rsivasan
3 Replies

9. AIX

Telnet Credentials

Dears i am going to write a shell script to do some administration jobs and automate them , but i need to access remote servers through telnet so my question is how to pass the required credentials to telnet through shell script or can i use a file and redirect the standard input to be from that... (3 Replies)
Discussion started by: TheEngineer
3 Replies

10. Linux

Passing variables to sql from batch shell in linux

Hi, I need to put this command in a batch shell. sqlplus -s user/password @test.sql and in the test.sql I have this command select * from pbempl where pebempl_id = $1; How I can pass the variable $1 from the batch shell??? Thanks (2 Replies)
Discussion started by: rama71
2 Replies
Login or Register to Ask a Question