I am using expect to auto login on SSH from an Unity launcher, the command looks something like this:

gnome-terminal -t SSH1 -e "expect -c 'spawn ssh root@111.222.333.255 ; expect assword ; send \\"password123\\n\\" ; interact'"

That works fine for logging in automatically, but if I maximize the gnome-terminal window, the ssh shell contents remain smaller as if the window had the default size, like this:


At first I thought it was because the gnome-terminal was being launched with the default size and when maximized for some reason the ssh stuff didn't resize, but then I added gnome-terminal --window --maximize to the command, and the same problem remains, the window starts maximized but the ssh shell text still is the size of the default terminal.

Also if I just open a terminal and type that command on the top, I have the same problem as if I start it from the Unity launcher.

Any ideas what could cause this and how to fix it?

  • 4
    Not an answer: using ssh with ssh-keys works great, you can resize, and it is more secure than writing the pain password in a command (probably put in a script or an alias). So, why don't you use ssh-keys? (Also, I cannot get your command, opportunely modified, to run, so I cannot try). – enzotib Jan 8 '12 at 17:12
  • @enzotib I will take a look at ssh-keys but I never used them, Im not sure how to set them up. And its weird the commands doesn't work for you, I just copy paste the cmd on my question into a terminal, and it works. – nirgxx Jan 8 '12 at 17:46

a better way to get the effect you want is to use ssh keys like enzotib suggested.


$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ ssh-keygen -t rsa

press enter at each prompt leaving the fields blank will create a default key with no password. This is what you want.

Next push the public key to the server.

$ ssh-copy-id root@111.222.333.255

Finally create a launcher with the command:

gnome-terminal -t SSH1 -x ssh root@111.222.333.255
| improve this answer | |

Use following on the top of your expect script:

#trap sigwinch and pass it to the child we spawned
trap {
 set rows [stty rows]
 set cols [stty columns]
 stty rows $rows columns $cols < $spawn_out(slave,name)
| improve this answer | |

This has to do with the environment variable that Expect uses for your terminal setting.

This can easily be fixed by adding the following line to the beginning of your Expect script:

set ::env(TERM) vt100

I found that if you have any colorized characters. If you want to see colorized characters, you can also try:

set ::env(TERM) xterm
| improve this answer | |

Add this to your code:

trap {
    set XZ [stty rows   ]
    set YZ [stty columns]
    stty rows $XZ columns $YZ < $spawn_out(slave,name)

This appears to be working for me on Ubuntu 17.10

| improve this answer | |
  • Isn't it just the same with @Anish Sneh's previous answer...? – GyuHyeon Choi Jan 30 '19 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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