Link to home
Start Free TrialLog in
Avatar of nohurt
nohurt

asked on

sftp client authentication methods

I'm trying to connect to an sftp server, but am unable to do so through a bash script.  the server is expecting ssh key authentication by default and i'd like to do UserName/Password auth.  Is there a way i can specify the type of auth i want to use and if so what are some examples?  Such as:
sftp -oAuthenticationMethod=Password MyName@ftp.ExampleServer.com
or
sftp -oAuthenticationMethod=SSH_KEY MyName@ftp.ExampleServer.com

I've tried using the -o options, but am not sure i got the syntax right.
also, i interactivly try and connect to the sftp server it will prompt me for a password and when i enter it, it's just fine.
i'm running the bash script on Linux machine which is trying to connect to a sftp server running on windows machine.
SOLUTION
Avatar of mchkorg
mchkorg
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Member_2_908359
Member_2_908359
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nohurt
nohurt

ASKER

i'mtrying to connect to a partner who is hosting the sftp server on windows.  i'm not sure what server they are running.  they have asked that i connect to them using "sftp UserName@sftp.PartnerName.com".  When i do that interactively from command line on a linux box, the sftp server prompts me for my password, i enter it and all is fine.  When i try and connect using (through a bash script):
expect << 'END' 2>&1 | tee -a $LogFile
set timeout 5
spawn sftp $env(UserID)@$env(HostToConnectTo)
expect "UserName@ftp.PartnerName.com's password: "
send -- "$env(Password) \r"
expect "sftp> "
send -- "cd $env(OutPutDir) \r"
expect "sftp> "
send -- "ls -l ../ \r"
expect "sftp> "
send "bye \r"
END
 
The partner has not "White listed" my ssh key on their server, so it doesn't work.  I would like to know if there is an option for sftp so that i can be very specific on sftp command line the use of authentication (password or ssh key).
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nohurt

ASKER

my authorized_key is in the file. If i "sftp username@server.com" i get in just fine and am at the sftp> prompt.  But if i try and ssh or scp a file, it just hangs.  i'm not sure what's going on.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nohurt

ASKER

it turns out that the ftp server i connect to has to accept my ssh key on their side manally in the sftp server.  i am not allowed to put a public ssh key on their server.