Hi everyone, I am having problems with changing a script (originally it is used to transfer file from an FTP server to another place). Now the company change the FTP to SFTP server, so I need to change the script accordingly.
Basically, I have trouble with the log in authentication, here is the old log in part:
The generating log in file is in the same file as the rest
Now, when I look online for sftp log in credential, it seems that I need a separate log in file and an cmd file to do other thing, here is the sample:
The point is if I generate out a log in file like that (which needs a cmdFile tp run) then I will not have the cmdFile at that time since the code gor the other part is generated after the login part (in the original file)
I know this maybe very confusing (since I am also quite confused with this whole ftp - sftp thing), I hope you guys can help me out a bit. Many thanks
Oh, one last thing, just asking: regarding commands, is there any difference between sftp and ftp
The syntax should be about the same for sftp, but the authentication works different, as you already noticed. You can't supply user and pw this way. Either your exchange ssh-keys (there is plenty of topics about this for "passwordless ssh" here in the forums as well on the www) or supply it manually, where the latter you don't want to. You can automate it also using expect to feed the credentials. There should b also some posts here in the forum about it you can find, using the search function.
send one (or some) commands as now authenticated user
close the connection
With "sftp" you:
exchange ssh-keys instead of user/password before you even attempt to transfer files. You do this only once. The "session" itself is:
connect to the other server
system automatically supplies the authenticating key
send one (or some) commands as now authenticated user
close the connection
The advantage is: you do not have to put passwords in clear text into scripts. Instead you exchange a secret (keys) once and then use these automatically. These secrets are not being sent in clear text over the network either (unlike "ftp", where passwords are transferred that way), which further enhances security: nobody listening on the network can collect the secret and then use it himself.
Things you have to consider: if you have a firewall between the two systems make sure you have the necessary ports opened. "sftp" operates (usually - can be configured) on another port than "ftp" (usually) does.
HI, thanks for your help, I know there are posts out there talking about ssh key, but I hope you guys can help me again, so now I have the username and password for the SFTP server. Will I have to somehow generate this username and password into a ssh key; or I can create a separate ssh key (separate from my existing user name and password).
If there is any sample code for such procedure, I would be really appreciate, thanks
Will I have to somehow generate this username and password into a ssh key; or I can create a separate ssh key (separate from my existing user name and password).
This actually is discussed in the man page of "ssh" at length. I suggest you read this.
Suppose you are userA@hostA and want o connect to hostB as userB:
Basically, you connect to the remote system once using standard username/password authentication. Then you generate an ssh-key on this remote system as the authenticated user. Transfer this generated key (this is a long string, you can either put it into a text file and transfer this, but even copy&paste would work) to the machine you connected from. There you have a "keyring" file ("hostA/~userA/.ssh/authorized_keys"), where you simply append this string. From now on, when you attempt to connect to hostB as userB coming from hostA as userA the ssh (or sftp) software provides this key and the remote system - instead of asking a password - takes this as authentication.
Note that this will not work both ways: the above would only provide passwordless access as userA@hostA to userB@hostB. To connect to hostA as userA coming from hostB as userB you would have to generate another key and transfer it in the other direction first.
Note also that this only authenticates a single host/user pair: If userA@hostA can connect passwordless to hostB as userB this neither means that userB@hostA can do the same or that userA@hostA can connect as userA@hostB without a password. You would have to generate and exchange keys first as these user/host combinations to make it work.
Another thing: generate keys only ONCE. If you want to connect as userB@hostB coming from userA@hostA as well as userB@hostA then connect to hostB as userB first, generate the key and put this key into the keyring file of userA@hostA as well as userB@hostA. Do NOT generate 2 keys!
Hi All,
Seeking for your assistance on how to ftp or sftp from workplace to unix server?
i tried ftp user/pass but it says "command not found" i tried sftp user@localhost i can't connect.
Please advise,
Thanks, (1 Reply)
hi guys,
i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not
and again i have to reverse sftp the files from unix to windows server.....
regards,
Vasa Saikumar. (13 Replies)
Hi,
I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script.
Can anyone help me in automating the script such that it... (3 Replies)
We have RHEL 5.8 in our environment, I had a query whether we can implement an FTP server using vsftpd package and Linux configurations like setsebool without using any external FTP clients like FileZilla etc. I am very confused on this. The FTP functionalities that should be present are download &... (3 Replies)
hi, i want to write a shell script code which transfers files from a directory in unix server to a directory in a windows machine.. can any1 give me a sample code which uses ftp or sftp command..
thanks very much, (3 Replies)
hi
i need to transfer some files from windows server to unix server using SFTP. but before transferring the files, i need to check the
existence of a particular file in the remote directory (say r_dir1). if the file is present, then SFTP all the files.
after SFTPing the files from the remote... (1 Reply)
HI
I need to write a script in 415univ server which should go to 534unix server and move the files from there to windows server.
I am not able to get it bcoz sftp prompt is not allowing ftp command.
Can some one plz help me
Thanks in advance (3 Replies)
Hi,
we have a big problem,
history:
we migrated our companies ftp and sftp-server, which were vsftp and openssh, to one server, software is called JSCAPE ftp server professional edition
for the first time everything was great, but after one or two months, our uploads hang, 0 byte files are... (11 Replies)