Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Common multiple SSH connections file handling issue

I used to do something like that often:

home $> ssh user@server1
user@server1's password:
server1 $> ssh user@server2
user@server2's password:
server2 $>

Server2 is available from server1 only, so I have to do stuff like that all time.

So, question is. How can I do 2 consecutive logins in one command?

home $> ssh_many user@server1 user@server2
user@server1's password:
user@server2's password:
server2 $>
share|improve this question

marked as duplicate by Gilles, Michael Mrozek May 11 '11 at 21:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers 2

up vote 4 down vote accepted

Try using the ssh -t argument.

ssh -t user@server1 ssh user@server2

From the man ssh page:

    -t      Force pseudo-tty allocation.  This can be used to execute arbi‐
                 trary screen-based programs on a remote machine, which can be
                 very useful, e.g. when implementing menu services.  Multiple -t
                 options force tty allocation, even if ssh has no local tty.

This should give you what you are after.

share|improve this answer

You are probably more interested in a way to directly access server2 from home. There's a simple solution to use your connection form home to server1 to create a tunnel that will allow you directly ssh to server2 from home. You can then also do other protocols like SFTP or Rsync over SSH straight between the two. As Gilles suggested, look at Common multiple SSH connections file handling issue

share|improve this answer

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