The .netrc file is generally used for FTP connection credentials etc., however you seem to want to use sftp which is another thing altogether.
SFTP uses files in (typically) ~/.ssh to store all sorts of things but it's quite different to plain FTP so you can't just copy things around.
More usually you would create a batch file of commands you want SFTP to perform and call them with a -b flag. You would need to either answer login prompts or create an SSH key pair, putting the public key on the target server.
How much do you know about SFTP use, authentication, etc.?
Whilst the general commands within sftp are very similar (get, put, rename, chmod etc.) the mechanism is very different. The connection is designed to be secure, so you cannot force a user & password into it like this:-
....or other forms of pushing input into tools. SSH & similar tools have been designed with their own way of working, the exchange of encryption keys. More goes on than you need to know but the important bits for most of us are that the credentials are generated by the client side in the form of two keys. The private one remains on the client side and is used for decrypting the incoming data, and the public key can be shared around.
If a server has a public key (or multiple public keys) stored in the correct place in a secure manner, the owner of the private key is able to connect with a passphrase. Often, for automated tasks, this passphrase is null so the login becomes automatic.
The process to follow to set this up would be:-
Generate a pair of keys, usually using ssh-keygen
Copy the public key (written to ~/.ssh/rsa_id.pub or ~/.ssh/dsa_id.pub by default) to the server you wish to connect to.
Append to (or create) the file ~/.ssh/authorized_keys with the contents of the public key
Check that the permissions for ~/.ssh are 700, owner for the correct user.
Check that the permissions for ~/.ssh/* are 600, owner for the correct user.
You should then be able to open an ssh connection which will ask you to store the fingerprint details which means you are accepting the public key of the server you are connecting to.
The public keys are used to encrypt the data and the private keys are used to decrypt it, but this then becomes automatic from your point of view.
After you can open an ssh connection, you should be able to use sftp in your script. Depending on how complex your needs, you might be able to use a here document like this:-
....or you could create a batch file like this:-
Have a go, and let us know if you get stuck. I have probably missed something or not explained it clearly so it probably won't work first time. I must say that I have never used macdef so I'm not sure how this could be written, but there are bound to be options.
my understanding is on SFTP is only that he its a secure FTP and and works on port 22 instead of 21.
It's an entirely different protocol, ssh, emulating FTP for convenience's sake.
What it does not -- will not -- cannot do, is use stored passwords. It intentionally does not support .netrc, or passwords over pipe, or passwords over commandlne, or passwords over environment, or any other insecure way of storing passwords. This is a security feature. This breaks a lot of designs of old - a lot of bad, insecure designs of old.
You have to generate a set of key files in advance, and share them with the server, before you can noninteractively login instead.
Hello,
I am on a Mac and trying to clean up some monthly files with a very simple SED:
sed '3,10d;/<ACROSS>/,$d' input.txt > output.txt
(from the input, delete lines 3 - 10; then delete from the line containing <ACROSS> to the end of the file)
then output to output.txt
Even when I try... (2 Replies)
I am running an old IBM P-Series server running AIX 4.3 (I know a dinosaur). The OS has not been updated.
We had a hard drive failure last weekend, and I was able to get most of the system back up, however, I have 3 line printers and 3 label printers that I can not get working. I have tried... (2 Replies)
Dear all,
I am totally despaired and puzzled.
Using Filezilla under Windows under the same network as our Linux servers is working. Using FTP command-line client under any of our Linux debian servers is not working ! I tried with different FTP servers -> same problem !
All commands are... (12 Replies)
What is the proper format for configuring the netrc file for linux. On Solaris it was:
Machine <machinename> login Domain\\login password passwordname (1 Reply)
Hi Guys,
I have never seen this happen before, but created a directory as a user when installing some software, software install fails so I try and remove the directory as root and get an error. There is no processes using the folder see output:
ls -l
total 446336
-rwxr----- 1 u0008862... (2 Replies)
Hello,
I'm running AIX 6.1 box.
I tried to use suid on binary file but it doesn't work.
(I set suid on /usr/bin/sleep and tried to run it as user1(sleep owner is bin) - and program still runs as user1. It shoud run as bin isn't it ? - This test run as expected on Linux box)
Filesystem is... (3 Replies)
Hi Guys,
I tried to schedule a script for every 5 mins. i tried */5 but it is not working.
Is writing every 5 mins is the only way to do it?
like below
05,10,15,20,25,30,35,40,45,50,55 05-08
Thanks And Regards,
Magesh (11 Replies)
Hi all,
I had a large application created using Visual C++. I ported that application using WINE to the Linux platform (ofcourse x86). Now I have to port the same application to AIX which runs over IBM mainframe. I dont have mainframe available but it is required for me to port my application to... (1 Reply)
I'm working on an AIX box, and I generall prefer emacs command line editing in ksh. Most control-commands are working, except not control-P (Recall previous command).
ksh
set - o emacs
^p
Does not result in the expected outcome.
does anyone know why this might be? (0 Replies)