Connect to ftp using .netrc with multiple accounts - linux

I have created a .netrc file so i can have some macros and automatically make some standard operations inside my ftp server.
The problem is that now every time i connect to this machine it always connects with the same account automatically ,without giving me the option to select an account for this machine.
I found this question inside stackoverflow,but seems that there is no answer that can help me.
Link to similar question
Thank you all in advance

In a .netrc file, each line referring to a particular machine looks like this:
machine booster login baxter password swordfish
machine wooster login francis password sw0rdf1sh
This will define the logins for two machines: booster and wooster. If you put in a line like this:
default login root password secret
This will be used for any other machines you haven't already listed.
Macros can be defined for each machine, and are defined after the machine or default line. The macro is defined by the line macro followed by the macro name. If the name is init, that macro will be executed automatically by the system.
You need to define separate machine lines for each machine you are logging into, and then have a default line for all other machines (if so desired).
You can also tell ftp not to read in the .netrc file by doing one of the following:
$ ftp -n
You can also use another net resource file besides the default .netrc:
$ ftp -N my.netrc.file

Related

Adding cent os user by editing configuration file

Im using cent os 6 for my work. For educational purposes I want to add user to the cent os by only editing configuration files.I know we can easly add user by useradd command and change their password using passwd command. But I need to use exactly above mentioned way. To do this first I need to understand what are the files I have to change
By searching I found that following files are responsible for handling user
/etc/passwd
/etc/group
/etc/shadow
/etc/gshadow
What I did is first I add the user using useradd command and then study the strings that commands created in above files. And then I try to replicate it with manually editing files using VI editor. After I replicate every line of string I make a directory for my new user in /home. the I reboot the VM and try to login as manually created user. I can log in without any problems but the terminal showing bash-4.1$ instead of my username. but when I use whoami terminal prints my username correctly.
My question are
Is there any other files do I need to modify to add user successfully?
By adding user manually what are the functionalities that user lost ?
How to create MD5 hashed password for manually created user ?
I know to you this is may be little bit odd. but I need to do this exactly this way. If this question is inappropriate please let me know without down voting
thanks
Those are the essentials, obviously you'll need to create a home directory for that user with proper permissions, as well as any additional user specific resources.
You might want to also read up on the Pluggable Authentication Module or PAM. This provides increased authentication functionality to Linux beyond passwd, group, shadow files.
Also check out the GETPWNAM() system call.
=D Enjoy the Posix!
Serverfault on password hash creation below.
REF: https://unix.stackexchange.com/questions/81240/manually-generate-password-for-etc-shadow

Informatica creates a zero byte file and then can't write to same file

I have an Informatica workflow that is supposed to generate a .dat file.
The issues is that the wroflow creates a 0 byte file, but then can not write to the file it JUST created. It's baffling.
The target directory is a linux server, and there is a developer on our team that is able to run the workflow just fine, without this file-writing issue.
However, I have checked with our linux admins and several of them have confiremd that there is no major difference in access/permissions between her linux ID and my own. She is in two more user groups than I am, but I have been told that they would not have anything to do with this issue.
The ID used by the connection object is also in the same user group as my id on the linux server, enduser. Therefore it should be able to write to my home directory.
The workaround we have devised is to remove the files using my id, touch the files and then chmod them. This allows the id used by the Informatica connection object to write to the files, but it is not a permanent (or correct) fix.
My best guess is that this is most likely some sort of (very obscure) Linux environment issue.
I am also not able to make any changes to the Informatica workflow or mapping, since it is built correctly and this issue appears to be completely local to certain linux user ID's.
Does the etluser have write permissions? have you tried running a post session command script for chmod and giving full permissions and then writing into the file?

Storing securely passwords for connection to DB in opensource projects

Cloud9 is a cool service. IF you create a workspace that is public it will mean that everyone who knows your project url and have an account at cloud9 can browse and download your code. This means that if my project have, for example, connectivity to mongodb, everyone will see login and password to connect to mongo (because it will be in some source file).
The only option I can see to store passwords securely (except making project private) is to somehow add them to environment variables, and use process.env.XXXXXX call within the code. This seems to be secure because even if others may browse my code they cannot open terminal and check what environment variables I have defined.
So, is there a way to add my custom environment variable(s) to that they would be accessible via process.env.XXXXXX inside node's code?
You can define environment variables in ~/.profile. Files outside of the workspace directory /home/ubuntu/workspace are not accessible for read only users. You can do e.g.
$ echo "export SECRET=geheim" >> ~/.profile
to define the variable SECRET and then use it through process.env.SECRET from your application. The runners (from the "run" button) and the terminal will evaluate ~/.profile and make the environment variable available to your app.
When running project with cloud9 runners there is Environment popup on the right side of the runner toolbar. You can use it to add environment variables the way you want, but make sure to not add a name to the config since configs with name are automatically saved in .c9/project.settings
Another solution is to create a file in the directory not exposed in readOnly mode. e.g
echo "password" | sudo tee /xxx
you can even edit /xxx file using vi inside cloud9 terminal.
But Of course the best solution is to buy premium subscription, and get more private workspaces:)

Using SAS X Command with PCFILES server

I have some SAS code that writes out to a specific sheet in an excel workbook. The other sheets have formulas that look to this sheet so the workbook is basically a template that gets populated when my code is run.
I want to be able to run the code multiple times, and end up with a different version of the template each time it is run. I'm thinking the easiest way to achieve this is write out to the template and then use x command or something to copy the workbook and then rename it.
SAS is on a linux server and I use a pc files server to write to excel. How do I set up x command to copy the file and change its name on the remote server?
Sorry for the late answer, but I just encountered this myself and can provide a solution.
Can you access files on the sas server through windows (with an SMB share or similar)? That is the easiest way to do this. If you can't, it is typically very easy to set up Samba on linux.
First, store the excel template on the SAS server where it can be seen from your windows computer (with the PC Files Server on it).
Lets say the file is in '/home/files/template.xlsx' on the SAS server, and that directory is shared and accessible on your windows server as '\linuxservername\files\template.xlsx' (or \192.168.1.5\files\template.xlsx if you are using IP addresses)
Now you just have to use the SMB path for the PCFILES stuff and the local linux path for the x command. Something like
x 'cp /home/files/template.xlsx /home/files/output.xlsx';
libname output PCFILES
path='\\linuxservername\files\template.xlsx'
server='PCFilesServerName'
port=1234;
Note that when feeding a path to PCFiles, you use the network address (since your windows box has to be able to read and write it) and when you issue the copy command, you use the local address.
You may also be able to use the network path for everything depending on your system configuration. When I tried it, I could not make it work since the unix server did not like it (it shares the folder over SMB, but it didn't know how to access it from the command line).

Windows command line GIT password prompt

I have mysysgit and TortoiseGit installed on a Windows PC, which connects to a remote Git repo on a Linux box. I have created ssh keys, and added them to the profile in TortoiseGit. When I interact with the remote repo in TortoiseGit, it all works fine. No password prompting. However, when I try to run Git commands from the command line, I get prompted for the SSH password.
What do I need to do so that I'm not prompted for the password from the command line?
Make sure your git session references the TortoisePLink.exe (in GIT_SSH environment variable), as described in "Why git can't remember my passphrase under Windows":
(you might have done the first two steps already)
convert your key for use with TortoiseGit's pageant.exe using TortoiseGit's puttygen.exe.
Run TortoiseGit's pageant.exe, open your .ppk file ("Add Key"), and provide your passphrase for your key.
add the environment variable:
GIT_SSH=C:\full\path\to\TortoisePlink.exe
This assumes your TortoiseGit is using TortoisePlink.exe.
The OP scott80109 concludes in the comments:
msysgit was installed to use Open SSH.
I changed it to use plink, and it now works without a prompt
Erez A. Korn adds in the comments:
I prefer to use openssh as it doesn't require me to have my key in an alternative format (ppk).
I've written a small wrapper to launch the ssh-agent and take care of business and then added it to my Windows Startup.
You can check the code in erezak/ssh-agent-wrapper-win.
I recommend to use pageant. read this http://guides.beanstalkapp.com/version-control/git-on-windows.html and add you ssh-key to pageant. it affects globally.
My use case needed multiple github users with passphrase-protected ssh keys.
I sorted my ~.ssh/config file to use different keys for different repo domains, as described here
However, I don't want to type my passphrase every time, and I don't want to use ssh-agent.
Here's how I set up Pageant to ask for and remember my passphrase on Windows login:
Download the Putty Tools package
Win+R to open run dialog
shell:startup to open the auto start folder in windows explorer
Navigate to your Pageant folder in a separate Explorer window
Right click and drag PAGEANT.EXE to the Startup folder. Choose Create Shortcut
Right click the shortcut, properties, Shortcut tab
Find the path to your .ppk encoded keypair
generate one with PUTTYGEN.EXE if you need a new one
convert one with PUTTYGEN.EXE if you have a linux id_rsa file but no .ppk
win7+ : shift right click your key in Explorer, Copy as path
Append the key path to the C:\whatever\PAGEANT.EXE line
e.g: "Target: C:\putty\PAGEANT.EXE plato_cambrian.ppk plato.ppk"
If your keys aren't adjacent to PAGEANT you can use absolute paths or change "Start in:" which is Pageant's CWD
Open the shortcut or reboot, and type your passphrases
Also, for anyone on ubuntu/linux mint who ended up here, I documented similar steps here

Resources