LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-15-2014, 01:52 PM   #1
edimanic
LQ Newbie
 
Registered: Jan 2014
Posts: 10

Rep: Reputation: Disabled
SFTP connection to server


hello all ,

kindly help me on below issue .
i want to connect to remote server through SFTP .

i am using below commands .
but still it is not taking the password and keeps the screen hold for password .
=======================================
sftp -v userid@serverhost
sleep 1
expect Password:
send "password\n"
=======================================
 
Old 01-15-2014, 02:10 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by edimanic View Post
hello all ,
kindly help me on below issue .i want to connect to remote server through SFTP .

i am using below commands . but still it is not taking the password and keeps the screen hold for password .
=======================================
sftp -v userid@serverhost
sleep 1
expect Password:
send "password\n"
=======================================
You haven't replied in your other thread that's SFTP related. You are aware that if the remote system sends "password:", that it is NOT the same thing as "Password:", right?? And you're not putting Password: in double-quotes. There are MANY easily-found examples for SFTP/expect scripts:
http://www.unix.com/shell-programmin...pt-except.html
http://jibbysununix.blogspot.com/201...ct-script.html

Again, as with your other thread, you're not providing full details/goals. One of the BIG advantages of SSH/SCP/SFTP, is that you can do passwordless logins by doing a secure keyswap. This not only makes things secure, but keeps you from having to put a password into a script, WHICH IS A BAD IDEA. You're making a secure process INSECURE.
 
1 members found this post helpful.
Old 02-03-2014, 12:34 PM   #3
edimanic
LQ Newbie
 
Registered: Jan 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Hi ,

yes i agree , but our system port and host may be change so i need to connect using password only .
i am using expect command but it is giving me error as
expect: command not found
send: command not found

i am not sure if i need to declare or define expect and send command somewhere ....

plz help me ASAP...
thanks..
 
Old 02-03-2014, 01:08 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by edimanic View Post
Hi ,
yes i agree , but our system port and host may be change so i need to connect using password only.
Sorry, but a changing port/host isn't a good reason to not use passwordless connection. It's TRIVIAL to change a script to use a different port, and takes a few seconds (one time!), to upload your key. Adding the flag to use a different port will also take a few seconds to any script you have. And really...how often would your port/host actually be changing?? Unless it's changing a few times a day, there's no reason to use expect. Even IF your host/port changed every single morning, it would probably take you less than one minute to modify your script to work.
Quote:
i am using expect command but it is giving me error as
expect: command not found
send: command not found

i am not sure if i need to declare or define expect and send command somewhere ....
plz help me ASAP...thanks..
You need to spell out your words, and don't use things like ASAP. We VOLUNTEER our time here, so telling us to hurry up and help you is fairly rude. And since you don't post your script, it's hard to tell you why it's not working. Post your script and we can try to help...but the first thing to check, would be to make sure that you have expect installed on your system.
 
1 members found this post helpful.
Old 02-03-2014, 01:16 PM   #5
edimanic
LQ Newbie
 
Registered: Jan 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
Apologies for my words....
could you please advise how to check if expect is installed in system or not ..
thanks....
 
Old 02-03-2014, 01:23 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by edimanic View Post
Apologies for my words....
could you please advise how to check if expect is installed in system or not ..
thanks....
Not really, since you don't tell us what version/distro of Linux you're using. You can TRY to type in "expect -version", but if it's not in your path, it won't work. Look in your package management utility to see if its there. And again, even if it IS installed, unless you post your script, there's little we can help with.

Again, WHAT YOU ARE DOING IS A BAD IDEA, and there is NO reason to do it. Use SSH with a keyswap, keep things secure and easy to use.
 
Old 02-03-2014, 01:58 PM   #7
edimanic
LQ Newbie
 
Registered: Jan 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
thank you for helping me here ..
my script is already ready with the ssh keys but my client insisted to use password based connection .

he is not accepting with ssh keys .

expect -version ==> is giving me error, command not found
and my Linux version is ==> Red Hat Enterprise Linux Server release 6.2 (Santiago)

Script#

#!/usr/bin/expect
set user user
set pass pass
set host host

sftp -v $user@$pass
expect "Password"
send "$pass\r"

put filenameWithPath
bye

Error#
line 7 and 8
expect and send command not found
 
Old 02-03-2014, 02:01 PM   #8
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
What distro are you using?
 
Old 02-03-2014, 02:13 PM   #9
edimanic
LQ Newbie
 
Registered: Jan 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
it is 2.6.32-220.e16.x86_64
thanks.
 
Old 02-03-2014, 02:20 PM   #10
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
No problem.

Thats your kernel version.

What is your distro? Centos, Scientific Linux, Debian, Ubuntu, etc?
 
Old 02-03-2014, 02:30 PM   #11
edimanic
LQ Newbie
 
Registered: Jan 2014
Posts: 10

Original Poster
Rep: Reputation: Disabled
thanks .

Red Hat Enterprise Linux Server release 6.2 (Santiago)
 
Old 02-03-2014, 02:33 PM   #12
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
to install 'expect' you can run:

Code:
yum install expect
And if you have any issues -- you are paying for RedHat, so you can contact their support center for such installation questions.
 
Old 02-03-2014, 03:39 PM   #13
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by edimanic View Post
thank you for helping me here..my script is already ready with the ssh keys but my client insisted to use password based connection
he is not accepting with ssh keys .
Your story keeps changing here. First it was because your system and host might change, now it's your 'client' doesn't want to do it, then the system isn't accepting keys (??). Which is it? And since your script was already set to use passwordless connections, it seems VERY odd that you did that...knowing that your client didn't want to use it/the port and server may change. Why would you go through that effort for a script you knew you couldn't use?
Quote:
expect -version ==> is giving me error, command not found
and my Linux version is ==> Red Hat Enterprise Linux Server release 6.2 (Santiago)
And again, UNLESS YOU HAVE SOFTWARE INSTALLED, YOU CAN'T USE IT. How do you think an expect script is going to work, when you haven't installed expect???
Quote:
Script#

#!/usr/bin/expect
set user user
set pass pass
set host host

sftp -v $user@$pass
expect "Password"
send "$pass\r"

put filenameWithPath
bye

Error#
line 7 and 8
expect and send command not found
Right...because you don't have expect installed, and you haven't bothered to read the samples I sent you in post #2. There are errors in your script. Why didn't you even try to read the samples you were provided?

You need to use the spawn command with sftp, is just ONE of the errors.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sftp-server connection from windows7 to linux machine gajananh999 Linux - Networking 36 10-11-2012 12:57 AM
Sftp connection between Windows server and linux server vikash.thbs Linux - Server 2 01-02-2012 10:25 AM
[SOLVED] sftp, connection closed after successful connection. kaz2100 Linux - Software 1 09-30-2009 10:32 PM
cannot login into SFTP server using Net::SFTP cccc Programming 1 10-31-2007 06:23 AM
Files truncated by sftp/sftp-server at 65kb gato Linux - Networking 1 12-18-2003 10:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration