ssh profiles and scripts

776 views
Skip to first unread message

nickzoid

unread,
Nov 20, 2011, 9:09:58 PM11/20/11
to ConnectBot Users
Hello guys,

Im looking forward to use this app in the future, my question is there
anyway to setup some profiles so I can quickly connect to multiple ssh
servers without having to type much?

For example, I have few servers I need to type the password and "su -"
into it, does this app provides some sort of option to execute this
kind of commands or any other commands automatically based on the
profile? If you have a paid version I will be more than happy to pay
for it if it includes such features.

Thanks in advance.

Zurvan2

unread,
Nov 20, 2011, 9:42:00 PM11/20/11
to ConnectBot Users

After you have connected to a host, you can long-press on the
connection entry in the list and select "edit host".

Select the (unusually named) "Post-login automation". Here you can
basically write a script. Make sure to end it with a blank line to
send a newline and make the shell process the (last) command. Anything
you can do with a shell script you can basically do here. Be very
careful of using passwords, though, as anything you enter here will
probably end up in your command history on the remote host.

I don't know of any way to clone whole entries, but you can certainly
copy the script part and paste it into another entry for each host.

For any serious automation, I'd recommend ssh keys *between* the hosts
you are connecting to, with scripts living on the hosts and merely
called by connectbot. Editing the scripts on a phone is never going to
be as smooth as using a full keyboard.

nickzoid

unread,
Nov 20, 2011, 9:57:47 PM11/20/11
to ConnectBot Users
Thanks a lot for the quick response, the Post-login automation is what
I need, this tool is awesome.
The feature that lacks of is the option to have the ability to send
ie: a command/typed chars after a expected response from the server
ie: "Password:" some sort like Xshell for PC has.

I use to connect to multiple servers through a SSH gateway and need to
type few "su user, su -" passwords on the way so if you can this to
put this feature on the next release would be superb.

Thanks again for the quick support.

> > Thanks in advance.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

Alexander Skwar

unread,
Nov 21, 2011, 5:50:29 AM11/21/11
to connectb...@googlegroups.com
Am 21.11.2011 03:57, schrieb nickzoid:
The feature that lacks of is the option to have the ability to send
ie: a command/typed chars after a expected response from the server
ie: "Password:" some sort like Xshell for PC has.
You might want to have a look at the "expect" tool → http://linux.die.net/man/1/expect

Alexander
-- 
↯     Lifestream (Twitter, Blog, …) ↣ http://sup.skwar.me/     ↯
↯  Chat (Jabber/Google Talk) ↣ a...@skwar.me ; Twitter: @alexs77  ↯

nickzoid

unread,
Nov 21, 2011, 1:24:10 PM11/21/11
to ConnectBot Users
Thanks!

On 21 nov, 07:50, Alexander Skwar <a.sk...@gmail.com> wrote:
> Am 21.11.2011 03:57, schrieb nickzoid:> The feature that lacks of is the option to have the ability to send
> > ie: a command/typed chars after a expected response from the server
> > ie: "Password:" some sort like Xshell for PC has.
>

> You might want to have a look at the "expect" tool ?http://linux.die.net/man/1/expect
>
> Alexander
> --
> ?     Lifestream (Twitter, Blog, ...) ?http://sup.skwar.me/    ?
> ?  Chat (Jabber/Google Talk) ? a...@skwar.me ; Twitter: @alexs77  ?

nickzoid

unread,
Nov 28, 2011, 1:42:11 PM11/28/11
to ConnectBot Users
Hey guys,

I tried the expect command but unfortunately doesnt seem to do what I
need since I need a script for each server.
I need to connect to a box through connectbot and then once inside I
need to connect to another box (the real destination server), the
first one its some sort of gateway I need to use.

What would you suggest?

Thanks in advance.

> > ?  Chat (Jabber/Google Talk) ? a...@skwar.me ; Twitter: @alexs77  ?- Ocultar texto de la cita -

Alexander Skwar

unread,
Nov 28, 2011, 1:57:59 PM11/28/11
to ConnectBot Users
Hi.

On Mon, Nov 28, 2011 at 19:42, nickzoid <nick...@gmail.com> wrote:

> I tried the expect command but unfortunately doesnt seem to do what I
> need since I need a script for each server.

Why doesn't it do what you need? Why do you say, that it is a
problem, that you need a script for each server?

Your problem description is not so clear… :)

> I need to connect to a box through connectbot and then once inside I
> need to connect to another box (the real destination server), the
> first one its some sort of gateway I need to use.


Okay.

> What would you suggest?

Uhm, "expect"? Maybe you could post what you tried, what you
got and what you expected to get?

> Thanks in advance.

No problem :-)


Cheers,
Alexander

Shai Ayal

unread,
Nov 28, 2011, 2:03:23 PM11/28/11
to connectb...@googlegroups.com
On Mon, Nov 28, 2011 at 8:42 PM, nickzoid <nick...@gmail.com> wrote:
Hey guys,

I tried the expect command but unfortunately doesnt seem to do what I
need since I need a script for each server.
I need to connect to a box through connectbot and then once inside I
need to connect to another box (the real destination server), the
first one its some sort of gateway I need to use.

What would you suggest?

Not exactly what you asked for but ...
What you could do is connect to the gateway and do local forwards to the remote (i.e. local 8888 to box:22), and then connect again from android to localhost:8888. This will give you a direct connection to the box through the gateway.
Shai

-- 
SPT - persistent SSH tunnels for android.

Fred Cox

unread,
Nov 28, 2011, 2:47:00 PM11/28/11
to connectb...@googlegroups.com
Using the ssh agent functionality (search for agent in http://code.google.com/p/connectbot/wiki/FrequentlyAskedQuestions ) is much better than trying to get expect do what you want.  For one thing, your password is not stored on the intermediate machine.  You add the same public key into .ssh/authorized_keys on the ultimate destination machine, and let ssh agent forward the authentication through the intermediate host.

Fred

> Thanks in advance.

No problem :-)


Cheers,
Alexander

--
You received this message because you are subscribed to the Google Groups "ConnectBot Users" group.
To post to this group, send email to connectb...@googlegroups.com.
To unsubscribe from this group, send email to connectbot-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/connectbot-users?hl=en.


l00g33k

unread,
Nov 28, 2011, 4:37:36 PM11/28/11
to connectb...@googlegroups.com
I assume you always connect to the same gateway box, and then
from there to the real destination server. I also assume that you have
expect working on the gateway box. Won't it be possible to setup
post login command on ConnectBot to start different expect script
to connect to different 'real destination server'? Just setup as many
ConnectBot config as you have 'real destinatin server' and just
click the appropriate ConnectBot config to connect to different
server.


Hey guys,

What would you suggest?

Thanks in advance.

--

Dennis Rockwell

unread,
Nov 28, 2011, 7:03:59 PM11/28/11
to ConnectBot Users
nickzoid <nick...@gmail.com> wrote:

> I need to connect to a box through connectbot and then once inside I
> need to connect to another box (the real destination server), the
> first one its some sort of gateway I need to use.

Set up port forwarding in the connection for the first box that will let you connect through to the real destination. I use this for work (through an SSH proxy) to get to my desktop with VNC or plain ssh, and to the IMAP server for work email.

Your apps will connect to localhost:nnnn where nnnn is the local port you've forwarded.


Dennis

Sent from my Nook Color with K-9 Mail. Please excuse my brevity.

nickzoid

unread,
Nov 28, 2011, 8:09:38 PM11/28/11
to ConnectBot Users
Hey guys,

I appreciate all the responses and the help, many thanks.
I have to say that today I was in a rush and I have explained the
method Im trying to setup incorrectly, apologizes for that.

This is exactly what Im trying to do, From connectbot I connect to my
remote (my own) server, from there I have to connect to a server meant
to be used as a gateway (from work) and from there I need to connect
to the real destination server. You would say why dont avoid my own
server and connect directly to the remote gateway server, I simply
cant do that.

I have tried to find documentation about the ssh agent and port
forwarding for connectbot as I didnt understand how these methods
would work although I couldnt find any documentation explaining how
this works.

Thanks again and sorry for being such a pain!

On 28 nov, 21:03, Dennis Rockwell <prr65...@gmail.com> wrote:

l00g33k

unread,
Nov 28, 2011, 8:39:28 PM11/28/11
to connectb...@googlegroups.com
Ah! Say you have:

home
gateway
dest1
dest2
dest3

'home' config: connect home:22, forward 2222:gateway:22
login to home for forwarding local:2222 to gateway:22 (through home IP)
'gateway' config: connect localhost:2222, multiple forward
2223:dest1:22
2224:dest2:22
2225:dest3:22
login to gateway (forwarded by 'home') for forwarding by 'gateway' to
dest1, dest2, etc.
'dest1' config: connect localhost:2223
login to dest1 (forwarded by 'gateway' which is a local connect forwarded by home)
And you are at dest1
ditto for dest2, dest3.

I haven't tried this but you get the idea.

A confusing setup requires a confusing configuration:(
Good luck.


----- Original Message -----
From: "nickzoid" <nick...@gmail.com>
To: "ConnectBot Users" <connectb...@googlegroups.com>
Sent: Monday, November 28, 2011 5:09 PM
Subject: Re: ssh profiles and scripts

Fred Cox

unread,
Nov 29, 2011, 2:43:18 AM11/29/11
to connectb...@googlegroups.com
Once you figure out the ssh agent, it's so much more convenient than port forwarding.

In connectbot, long press on the host you want to set up the agent, then hit "Edit host."  "Use SSH auth agent" is "No" by default.  You can choose "Yes" or "With confirmation."  Now copy your public key to ~/.ssh/authorized_keys on "home" (you probably have this already), "gateway", "dest1", "dest2", and "dest3."

When you log into "home," the agent will be running, and you can do "ssh -A gateway."  This can go in your "Post-login automation."

From the gateway, you can ssh to the dest machines.

Enjoy,

Fred

On Mon, Nov 28, 2011 at 5:39 PM, l00g33k <l00...@gmail.com> wrote:
Ah! Say you have:

home
gateway
dest1
dest2
dest3

'home' config: connect home:22, forward 2222:gateway:22
  login to home for forwarding local:2222 to gateway:22 (through home IP)
'gateway' config: connect localhost:2222, multiple forward
2223:dest1:22
2224:dest2:22
2225:dest3:22
  login to gateway (forwarded by 'home') for forwarding by 'gateway' to
  dest1, dest2, etc.
'dest1' config: connect localhost:2223
  login to dest1 (forwarded by 'gateway' which is a local connect forwarded by home)
And you are at dest1
ditto for dest2, dest3.

I haven't tried this but you get the idea.

A confusing setup requires a confusing configuration:(
Good luck.



----- Original Message ----- From: "nickzoid" <nick...@gmail.com>
To: "ConnectBot Users" <connectbot-users@googlegroups.com>
To post to this group, send email to connectbot-users@googlegroups.com.
To unsubscribe from this group, send email to connectbot-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/connectbot-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "ConnectBot Users" group.
To post to this group, send email to connectbot-users@googlegroups.com.
To unsubscribe from this group, send email to connectbot-users+unsubscribe@googlegroups.com.

l00g33k

unread,
Nov 29, 2011, 12:30:43 PM11/29/11
to connectb...@googlegroups.com
Best way to learn something is to pretend you know and then listen!
Thanks.

----- Original Message -----
From: "Fred Cox" <sailo...@gmail.com>
To: <connectb...@googlegroups.com>
Sent: Monday, November 28, 2011 11:43 PM
Subject: Re: ssh profiles and scripts

>> To: "ConnectBot Users" <connectbot-users@**googlegroups.com<connectb...@googlegroups.com>

>>> To post to this group, send email to connectbot-users@googlegroups.**com<connectb...@googlegroups.com>


>>> .
>>> To unsubscribe from this group, send email to

>>> connectbot-users+unsubscribe@**googlegroups.com<connectbot-users%2Bunsu...@googlegroups.com>
>>> .
>>> For more options, visit this group at http://groups.google.com/**
>>> group/connectbot-users?hl=en<http://groups.google.com/group/connectbot-users?hl=en>


>>> .
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "ConnectBot Users" group.

>> To post to this group, send email to connectbot-users@googlegroups.**com<connectb...@googlegroups.com>


>> .
>> To unsubscribe from this group, send email to

>> connectbot-users+unsubscribe@**googlegroups.com<connectbot-users%2Bunsu...@googlegroups.com>
>> .
>> For more options, visit this group at http://groups.google.com/**
>> group/connectbot-users?hl=en<http://groups.google.com/group/connectbot-users?hl=en>


>> .
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "ConnectBot Users" group.

> To post to this group, send email to connectb...@googlegroups.com.
> To unsubscribe from this group, send email to connectbot-use...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages