Sftp

Hello friends

Good Morning

I have a problem with SFTP, the problem that asks me for the password and the shell stops, what I need is not to ask me for the password to take it from the variety I am giving

sftp   ftpsic@$NodoFtpOms <<END_SCRIPT
quote PASS $PassFtpOms

cd $RutaFtpOms
pwd
put $NomArch
pwd
ls
quit
END_SCRIPT

Consider moving to passwordless ssh/sftp by using shared cryptographic keys instead of a password.

2 Likes

what happens is that they want to execute that way but I don't want them to ask me for the passqord and ask me for it anyway

Sorry, but I cannot understand what you just said above, and please check your spelling before posting.

1 Like

what happens that inside a shell I have an FTP connection when it reaches the part of the key the shell asks me for the key and the shell is paused I need it to happen without asking for the key

You can use sshpass

Type "sshpass" in the search bar at the top of this page and you will get plenty of references from others with similar issues in the past.

(..... sorry you did not state the details of your OS so not sure if sshpass is workable .... )

The problem I have is that when I run the shell, after connecting to the sftp it asks me for the password and is waiting for the password and I need it to be taken from the Variable

sftp ftpsic@$NodoFtpOms <<END_SCRIPT
quote PASS $PassFtp
pwd
put $NomArch
pwd
ls
quit
END_SCRIPT


No.

The problem is that you are not correctly automating this as I have mentioned a number of times.

That is the problem. You are implementing this in the wrong way.

So, can you show us the output that you are getting? I'm wondering if you are being prompted for the SSH key passphrase as opposed to the remote user password.

A simple test would be something like:-

sftp ftpsic@$NodoFtpOms <<END_SCRIPT
dir
END_SCRIPT

If this doesn't work, then perhaps we can look at the process of creating and sharing keys for a password-less connection. The client that opens the connection should create the SSH key pair. The public key from the client needs to be copied to the server you are connecting to. The file permissions need to be suitably tight. If you open the files up to more access, then the ssh/sftp client and/or the sshd will reject them. Doing a chmod 666 ..... will break it.

Can you show us the output of ls -l ~/.ssh on the client as the executing user and on the server side as the targeted user? Do not share the content of the private keys on-line.

Thanks, in advance,
Robin