Is it possible to ssh login into a server automatically after that I open ConEmu? I am basically trying to run a macro immediately after that the task loads the command line.
2 Answers
First of all, hardcoding logins/passwords is a bad approach.
Much better would be using ssh-agent.
But, of course, it's possible to use GuiMacro to type anything in the created console.
Well, supposing that bash.exe
is available through %PATH%
,
you may create the Task
using the following command:
bash.exe -c 'ConEmuC -Silent -GuiMacro Print "login" -GuiMacro Keys Enter -GuiMacro Print "password" -GuiMacro Keys Enter ; ssh your-server'
Bash makes me crazy... instead of simple -GuiMacro Print "login\npassword\n"
you shall use four -GuiMacro
blocks... I failed to let bash pass quotes
properly as ConEmuC arguments.
I do this
- Install Cygwin and Openssh
- Use a ssh key and authorized key on the server.
Create a .bat file with the code below in it
@echo off
C:
chdir C:\cygwin64\bin
bash.exe --login -i -c "ssh [username]@[domain] -p [port] -D [port]"
Create a ConEmu Startup
Tasks
cmd /k RenameTab "MyTabName" & "C:\[path]\MyBatFile.bat"
I also pin ConEmu to the TaskBar, and use this task in the Jump List
-
Thanks a lot, this seems to be a simple and clean way to perform a series of commands at once, doing it in one line seems difficult to read. Do you happen to know where I can find the list of console commands I can use and the explanation? For example, what does
-i -c -p -D
mean? Is the order important? Oct 21, 2015 at 9:50 -
1basically google for: "man bash" and "man ssh". You can also type "man bash" or "man ssh" into your linux terminal and it will bring up a local copy of the manual which explains what the arguments do Oct 22, 2015 at 15:36