Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to set up file transfer for which I've received the following access info. But I'm not sure how to connect, having hardly used SSH before. The instructions I got are:

First: ssh user1@domain1.com, password: password1
then: ssh user2@domain2.com, password: password2

I'm on a Mac. What client and settings should I use?

share|improve this question
1  
To actually login to the second server, see also "How to (S)FTP to hidden server?" at superuser.com/questions/51783/how-to-sftp-to-hidden-server/… for a solution using ProxyCommand in .ssh/config. –  Arjan Oct 6 '09 at 21:18
add comment

migrated from stackoverflow.com Oct 2 '09 at 4:37

This question came from our site for professional and enthusiast programmers.

8 Answers

up vote 3 down vote accepted

Ok, apparently you said the first server is just a relay, so let's use a SSH Tunnel. Here is what you can do in Terminal:

ssh -N -t -x -L 45454:domain2.com:22 user1@domain1.net

After entering the password you will not see anything happen. (Alternatively: remove the -N to actually see the command prompt of domain1.net.) And then in Transmit, you ask to connect to:

User: user2

Domain (server): localhost

Port: 45454

Protocol: SFTP (SSH)

This should normally allow you to use Transmit to connect to the second server, through the relay of the first one.

When done, stop Transmit, and then in Terminal hit Ctrl-C to stop ssh as well. (Or, if you started ssh without the -N parameter, then type exit instead of using Ctrl-C.)

share|improve this answer
    
Stuck at user1@domain1.com's password: since last 20 mins although I entered the correct pass; –  Nimbuz Oct 2 '09 at 5:16
3  
You're not stuck, you're probably logged in, and should now continue with Transmit, and when done hit Ctrl-C in Terminal to stop ssh as well. (Or, in Terminal, hit Ctrl-C to stop your first attempt. Then try again without the -N. After entering the first password, you will see the command prompt of the first server. Leave that alone, and do your thing using Transmit. When done, go back to Terminal and type exit.) –  Arjan Oct 2 '09 at 8:33
    
As Arjan stated, you're not stuck. You can add the -v argument to see that it is just "idling". This is due to the -N argument, that says "Tunnel only", so it creates the tunnel, and do nothing else, until you quit (which will destroy the tunnel). So once the password is entered, you can just go over Transmit and login :) –  naixn Oct 2 '09 at 18:33
    
Perfect, worked! :) –  Nimbuz Oct 12 '09 at 11:56
add comment

try this on a terminal window
ssh username@domain.com
it will ask for your password later
if you don't know what a terminal is, search the spotlight for "terminal"

share|improve this answer
    
FYI, the spotlight is at the top right corner of the screen, with a search icon :) –  phunehehe Oct 2 '09 at 3:27
    
I've used terminal numerous times, just don't know why two logins. –  Nimbuz Oct 2 '09 at 3:58
    
This question is about transferring files via another system. a <- b <- c –  Peter Jenkins Mar 31 '13 at 11:22
add comment

The reason that there will be two logins is that domain2.com will be hidden behind domain1.com, and only accessible from within. This is often done for security reasons, or simply because domain2.com is on a different piece of network not accessible from the outside.

share|improve this answer
1  
Good deduction, Sherlock! :-) –  Arjan Oct 2 '09 at 9:05
add comment

It depends on what you need to do on these machines. Ususally, the best way is to use the command line. To do that, you simply open Terminal (/Applications/Utilities/Terminal.app), where you will be able to enter these commands.

If the only thing you need to do is copy files, then you can use Cyberduck or Transmit. It's an FTP client, but you can use the SFTP mode, which will be a sort of FTP over SSH :). (All servers might no support this mode, in which case you will have to use the scp command)

share|improve this answer
    
Yes, but here I've two logins and no "server" info? –  Nimbuz Oct 2 '09 at 3:26
    
If you have user1@domain1.com, your username is user1 and your server is domain1.com –  Matthew Scharley Oct 2 '09 at 3:28
    
@Nimbuz: The "server" is the part after the @. This means you'd have: Server: domain1.com, User: user1, Password: password1 –  naixn Oct 2 '09 at 3:30
    
Thanks, I'm able to get pass through the first login, but the directory is empty as its just a relay. Where do I use the second login info? –  Nimbuz Oct 2 '09 at 3:34
    
If I use the second login info directly in 'Transmit', it tries for a couple of mins and returns "Permission Denied" –  Nimbuz Oct 2 '09 at 4:05
add comment

From a purely command line perspective, you would do something like this:

In terminal window #1:

$ ssh -L 2122:domain2.com:22 user1@domain1.com

enter the password when asked (password1). In terminal window #2:

$ scp -P 2122 -o HostKeyAlias=domain2.com user2@localhost:/path/to/remote/file /local/file

entering the password when asked (password2).

The port number 2122 can be anything you'd like (above 1024 and below whatever the max port number is). The port number 22 should not be changed.

HostKeyAlias is set so that the host name can be looked up properly in the known_hosts file.

share|improve this answer
    
The scp example is unclear, but the rest looks right. 1) HostAliasKey should be HostKeyAlias, but you need to explain why it's necessary/useful or remove it as extraneous. 2) file destination is very unclear (easy to misread), so show an explicit local filename or swap the example so local is source: "scp -P 2122 /file/to/copy user2@localhost:/path/to/destination" or "scp -P 2122 user2@localhost:/path/to/remotefile ./localfile" –  quack quixote Oct 2 '09 at 12:18
    
Thanks for the HostAliasKey typo. –  Joe Casadonte Oct 2 '09 at 12:44
add comment

Open Terminal (in your Applications/Utilities folder), and type the commands as given. OS X comes with an SSH program.

There are GUI ssh programs, but the command line stuff seems like it's going to be more appropriate for this, since they're giving you the command lines already.

share|improve this answer
    
I have 'Transmit' app, can I use that? What do I choose - SFTP? –  Nimbuz Oct 2 '09 at 3:25
    
SFTP is an extension to SSH providing file transfer, but is not itself SSH. If all you need is file transfer, SFTP does what you want. If you need to log into the remote server and use its command line, you need a proper SSH program, either the command-line one that comes with OS X, or a GUI one like Fugu. –  Warren Young Oct 2 '09 at 3:30
    
Yes, I'll only need file transfer. –  Nimbuz Oct 2 '09 at 3:34
add comment

Only if you need to access the files quite often, and only recommended after the procedures using Cyberduck or Transmit have been successful (to ensure your credentials and all are fine):

Mount the domain2.com resources locally using SSHFS with FUSE for OS X (formerly packaged in MacFUSE, but that does not support 10.6 and up).

ssh -L -N 45454:domain2.com:22 user1@domain1.com
sshfs user2@localhost:/ ~/project -oport=45454,follow_symlinks,volname=Project

The second line can also be done through a GUI, using Macfusion, but then be sure to read the SSHFS notes about that.

share|improve this answer
add comment

What you are tying to do is quick tricky for a newcomer to SSH. Several of the answers here don't even understand what you are asking for!

I've found this guide really good to explain the process of connecting via another host. The diagrams really help.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.