8
3
how can I set a shortcut in conEmu to automatically open a new tab with cygwin, and automatically start a given command (say, ssh) ?
8
3
how can I set a shortcut in conEmu to automatically open a new tab with cygwin, and automatically start a given command (say, ssh) ?
6
So lets start with how to launch cygwin bash in a new tab. In my example I am using msys-git's cygwin bash because that's what I have installed:
The command I use is:
%systemroot%\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" --login -i"
So that's an interactive shell. If I want to run ls from inside of cygwin bash, I can use sh -exec
instead of sh --login -i
It would look like this:
C:\Users\JDearing>"C:\Program Files (x86)\Git\bin\sh.exe" -exec "/bin/ls c:\\"
+ /bin/ls c:
$Recycle.Bin VC_RED.MSI install.exe
BOOTSECT.BAK VC_RED.cab install.ini
Chocolatey Windows install.res.1028.dll
Documents and Settings boot install.res.1031.dll
EntLib41Src bootmgr install.res.1033.dll
Intel eula.1028.txt install.res.1036.dll
MSOCache eula.1031.txt install.res.1040.dll
PerfLogs eula.1033.txt install.res.1041.dll
Program Files eula.1036.txt install.res.1042.dll
Program Files (x86) eula.1040.txt install.res.2052.dll
ProgramData eula.1041.txt install.res.3082.dll
Recovery eula.1042.txt old_machine
RiskWorks eula.2052.txt pagefile.sys
SWSetup eula.3082.txt profiles
SafeBoot.fs globdata.ini sysinternals
SafeBoot.rsv hiberfil.sys vcredist.bmp
System Volume Information ilspy
Users inetpub
C:\Users\JDearing>
So you can probably start ssh from cygwin bash with something like:
%systemroot%\SysWOW64\cmd.exe /c ""C:\Program Files (x86)\Git\bin\sh.exe" -exec "/usr/bin/ssh Car981@linuxbox.domain.com""
You might have to play with quotes. I'd suggest looking at my conemu tasks for reference.
3
This is the most seemless way to get an SSH task up and running through ConEmu. Requires a bit more configuration, but it's worth it in the end.
Steps from excellent answer here: https://serverfault.com/questions/241588/how-to-automate-ssh-login-with-password. ssh-keygen will ask you a few questions. The default answers are fine. If you want to go with a blank passphrase, that's fine as well. Just keep your keyfile safe. Replace id, server and password with your credentials.
$ ssh-keygen -t rsa -b 2048
$ ssh-copy-id id@server password
$ ssh id@server
""C:\Program Files\Cmder\vendor\git-for-windows\bin\sh.exe" -exec "/usr/bin/ssh id@server""
If you did everything correctly, your console will start up and ssh into your server of choice, no password required since you're using a passkey.
2
C:\cygwin64\bin\bash.exe --login -i -c "ssh myUser@myServer"
the -c will execute the following string command automatically after logging in for you
The other answers to this question are quite expansive, can you elaborate on this at all? – bertieb – 2017-02-18T23:19:01.943
added some more – meffect – 2017-02-18T23:32:37.563
2I had to use
bash.exe -c "ssh ..."
rather thanbash.exe --exec "ssh ..."
– Michael – 2016-05-15T23:58:22.9903
cmd /c
is excess in fact, unless you need to set up any environment variables before running ssh.exe. If you don't need to set up environment - you may run ssh.exe directly, without "cmd /c". – Maximus – 2013-04-29T19:48:00.197If I run it directly, it doesn't attach to conemu though. What should I do ? – Car981 – 2013-04-30T06:19:12.197
1
@Car981 You need to add that to a task like this. Also look at -new_console
– Justin Dearing – 2013-04-30T15:52:10.247