LinuxQuestions.org
Visit Jeremy's Blog.
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 02-17-2010, 07:25 PM   #1
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Rep: Reputation: 0
how to sftp using a SOCKS v5 proxy


what is the command to sftp from one linux host to another linux host through a SOCKS v5 that requires authentication? I have tried:
Code:
# sftp -o "ProxyCommand netcat -X socks_proxy_host:1080 %h %p" external-server
I know this does not have auth in it but I was going to come to that later

output
Code:
Connecting to external-server...
netcat: invalid option -- 'X'
netcat -h for help
ssh_exchange_identification: Connection closed by remote host
Couldn't read packet: Connection reset by peer
the man page for netcat does not show an option -X but the openSSH man page does.
 
Old 02-17-2010, 08:55 PM   #2
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,706

Rep: Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271
Quote:
Originally Posted by digger86 View Post
the man page for netcat does not show an option -X but the openSSH man page does.
So why are you passing -X to netcat?

Evo2.
 
Old 02-17-2010, 10:19 PM   #3
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Original Poster
Rep: Reputation: 0
the -o option passes ssh options and the man page for ssh uses nc which is netcat.

From the OpenSSH man page:
Quote:
ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
This is not working so that is why I am asking.

Last edited by digger86; 02-17-2010 at 10:20 PM.
 
Old 02-17-2010, 10:54 PM   #4
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,706

Rep: Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271
Ok, now I understand. There seem to be two problems.

The -X flag for ssh forwards an X connection, which only makes sense for interactive sessions, not for file transfer. I know very little about netcat, so I can only assume that the -X flag is supposed to be passed to netcat, but your version does not accept the -X flag. So perhaps you need to work out what that is supposed to do and replace it with the correct option.

The second problem seems to be that you are not quoting the options correctly.
The example in the man page shows the syntax for an ssh_config file. The syntax on the command line would be
Code:
sftp -oProxyCommand='/usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p'
Evo2.
 
Old 02-17-2010, 11:01 PM   #5
evo2
Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,706

Rep: Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271Reputation: 1271
Ok, I just worked it out. You need to use the netcat from the netcat-openbsd package.

Evo2.
 
Old 02-18-2010, 10:55 AM   #6
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Original Poster
Rep: Reputation: 0
Thanks evo2, it make sense that the openbsd netcat will support it.

I was looking for a solution that does not require additional software. I guess I could always set up an ssh tunnel and then ftp.
 
Old 02-19-2010, 06:07 PM   #7
digger86
LQ Newbie
 
Registered: Jun 2009
Location: Oregon
Distribution: SLES, HPUX, SOLARIS
Posts: 24

Original Poster
Rep: Reputation: 0
how would you do this if you are just using SSH?
 
Old 01-25-2011, 11:47 AM   #8
skr989
LQ Newbie
 
Registered: Jan 2011
Posts: 1

Rep: Reputation: 0
This is an old post. Thought my input will help subsequent visitors to this forum.
Below is the command I used to connect SFTP via socks proxy
sftp -oProxyCommand='/usr/bin/nc -v -x10.10.10.10:1080 %h %p' user@sftp.host.com 22

Where,
10.10.10.10 is the SOCKS proxy host (DNS Can also be used)
1080 - SOCKS Port
sftp.host.com - Replace this with sftp host name
user - Replace this with the user id on the sftp server

In case you need to use a public/private key authentication here is how you can do.
sftp -oIdentityFile=/path/to/private-key-file/private-key.key -oProxyCommand='/usr/bin/nc -v -x10.10.10.10:1080 %h %p' user@sftp.host.com 22

You may need to give correct permissions to the private-key.key file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ssh over socks proxy d0x++ Linux - Networking 1 06-03-2009 02:35 AM
What socks 5 proxy to install? rosv Linux - Networking 2 11-06-2008 03:50 AM
RHE3: Socks Proxy Zai Red Hat 2 06-26-2005 07:55 PM
Kopete through a socks proxy NNP Linux - Newbie 1 05-30-2005 11:56 AM
Can I use ntpd through a socks proxy?? zhaoyoubing Linux - Networking 0 07-23-2003 09:24 PM


All times are GMT -5. The time now is 11:23 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration