In ConEmu, is there a way to create shortcuts to frequent ssh sessions? - ssh

I connect to several different SSH servers throughout the day. In OSX iTerm, you can simply press CMD+O to open all of the saved profiles and connect to those servers very quickly.
I have not found a way in ConEmu to setup any type of "favorites". From my research, it looks like that might just be a task in ConEmu, but I haven't found a specific answer.

Install Git for Windows which includes a few utilities.
Then in ConEmu create a new task.
The command for your new task will be:
""C:\Program Files\Git\bin\bash.exe" -exec "ssh user#XXX.XXX.XX.XX""

Related

Emacs Tramp smartcard config

I use ssh-key based authentication, with the keys being held on a smartcard. I am migrating to a new machine, where in my previous machine I had Emacs+Tramp set up nicely with the workflow.
However, now I am having issues. I found a solution, however I am wondering if there is a better way.
The setup
If I have an .ssh/config with the following entry:
Host remote
HostName 1.2.3.4
User root
remote has my SSH keys authorised, and if I run ssh remote in a normal shell, I am prompted for my smartcard pin, and can SSH with no issues.
However, in Emacs using tramp, I would normally ssh entering the filepath to ssh:remote:. However, in my fresh installation it instead prompts me for a username, and then a password.
First attempts
Following the suggestion of this answer, I increased the log level of tramp.
It showed me that tramp was running the following command: exec ssh -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none remote. Running this in a normal shell worked as expected.
I found that running ssh remote in eshell had the same problem.
I thought that maybe Emacs didn't have access to my ~/.bashrc config, where I configure my smartcard details:
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
The solution (is there a better one?)
This answer suggested launching Emacs with bash -c emacs.
This ended up solving the problem, however I wonder if there is a more robust solution, i.e. one encoded in my config.el file, or similar.
As you can see, the problem is caused by inconsistencies between the Emacs and shell environment variables. You can use exec-path-from-shell, especially if you are using macOS. Or you can just setenv manually. Finally, Spacemacs and Doom have their own way of handling it, I see you mention config.el, not sure if you are using Doom, you can refer to them as well.

How to launch Windows Terminal with multiple commands

I've been tinkering around with Windows Terminal lately, and I love how it consolidates all of the various terminal applications into one place. However, compared to the regular WSL Bash program, there's one thing I haven't been able to make it do yet - launch and automatically run a command.
This would be really useful to me because I need to run several services in the background while I develop - Redis, Chromedriver, and Postgresql. I can currently do this by having three separate tasks in Windows Task Scheduler, it would just be nice if I could run them all in a single Terminal window, not three.
I was reading through the documentation for Windows Terminal to see if this was possible, but came up empty. Has anyone been able to come up with a solution to the above?
Thanks!
You can run them all in a single tab but you will need to use split panes or tmux. You can use the split panes solution I provided in this Stackoverflow post.
Basically you create a profile for each command you want to run via Powershells -NoExit flag to keep the window(s) open. You can then launch those commands all as split panes in a single tab through Windows Terminal (wt.exe). Then just alias that command or put it in a shortcut to reuse it. Given that you setup all the proper profiles in settings.json the final command would look something like this (run it from cmd):
wt -p "redis" ; split-pane -p "chromedriver" ; split-pane -H -p "postgresql"
Or you could create a profile in settings.json to open your split pane commands from the WT dropdown menu, which would look something like this:
{
"guid": "{b7041a85-5613-43c0-be35-92d19002404f}"
"name": "bg_procs",
"colorScheme": "One Half Dark",
"commandline": "wt -p \"redis\" ; split-pane -p \"chromedriver\" ; split-pane -H -p \"postgresql\""
},

How to get GitKraken feature working - "Use local SSH agent"

In brief
What is the proper way to set SSH keys in GitKraken to work with different git github/bitbucket repos?
Full details
The feature is snapshot as below in GitKraken preference.
When I check Use local SSH agent, git pull/push/... commands stop working. Using git command from console works normally for me.
Currently I have to uncheck it, and select the ssh key I want to use which is quite tiring when working with multiple git repo providers.
My google search and search on our site result litle helpful, so I asked here.
Are you running gitkraken under linux? For me the problem was, that I had to export SSH_AUTH_SOCK for gitkraken to find the agent.
So I start gitkraken like this:
SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" /usr/share/gitkraken/gitkraken
It can be a rare case, but if it could help at least someone:
For me perosnally, having the same issue after installing gitkraken, it did help to restart the computer after installation. Everything worked then.

Reading profile script in non-interactive mode with AIX implementation of ksh

Please note that this is an AIX related question.
I have a jenkins server running on Redhat which is running a node via SSH on an AIX server.
The commands are run non-interactively using SSH to a user on the AIX machine who has ksh as its standard shell.
The problem is that this build needs a number of environment variables, and i can't seem to get it to work.
I have tried:
Jenkins allows me to set some environment variables for the session. So i tried:
ENV="$HOME/.profile"
I tried creating a .kshrc file containing
. .profile
But none of these approaches seems to make KSH run the .profile script.
The .profile script contains the environment setup for the user i need.
How do i get an AIX implementation of KSH to run my .profile script before executing commands?
You need to specifically tell Jenkins that you want to execute them in ksh shell.
By default, Jenkins runs as sh <commands>.
Add a shebang in your shell command as first line,
#!/bin/ksh
Most shells don't source their .profile files on non-interactive sessions. A simple solution is to source the .profile yourself as part of the command you are sending.
So instead of
yourcommand1; yourcommand2
you should send
. ~/.profile; yourcommand1; yourcommand2
over ssh
UPDATE after reading the comment about Jenkins controlling the ssh command
In the case your ssh command is performed by Jenkins you should have a look at https://wiki.jenkins-ci.org/display/JENKINS/SSH+Slaves+plugin, especially the 'Login profile files' paragraph.
I'd say one of these solutions is best
Set all environment variables from Jenkins using the node's configure page. Install the EnvInject plugin to do this.
Write a wrapper around the java command on the slave that sources your profile script and adjust the JavaPath (also on the node's configure page) to point to that wrapper.
The only way I know of for setting environment variables that will apply for non-interactive shells on AIX is via /etc/environment. I believe this is the correct place, but it will of course then apply to all users and all shells.

Using WinSCP script for SFTP access from SSIS

I am new to WinSCP and am attempting to create a script file that will eventually be used with SSIS to download files from an SFTP site. A lot of the literature WinSCP includes explains the file downloading or uploading portions. For the time being, I just want to create a script to test the connection first and will build from there.
So far I saved the connection in WinSCP and have the following. The below code does not seem to function at all and I am not sure where else to go as I am still reading about the scripting for WinSCP. Is there a way or can someone point me in a direction to see if I am in fact connecting via through the script?
option batch on
option confirm off
open username#address
exit
Not sure what SSIS is (sorry) but I can tell you how I'd set it up from a windows batch file if that helps:
If you are open to using a different software, consider using cygwin. It mimics a linux shell so linux users on windows have a lot of linux utilities handy. That being said, there are some commands which can run on windows straight from command prompt (and thus batchable). What you'd need to do:
1) install cygwin
2) Create a "passwordless" login (using ssh-rsa authentication). To do this start your cygwin terminal and use the commands "ssh-keygen" and "ssh-copy-id" (more on that later)
3) Now you can run "sftp" from the DOS command prompt (does not require cygwin terminal) and sftp to your account. No password required because of step 2).
A few follow up info:
What can run from dos command prompt and what must be run from cygwin terminal?
If you go to the "bin" directory of cygwin (for me it's in c:\cygwin\bin) you can see all the cygwin utilities. Anything with "exe" extension can be run from dos command prompt. If no "exe" extension, must start cygwin terminal first
How to set up ssh-rsa authentication?
You can pretty much google "ssh login without password" and pull up a lot of results. This is common for setting up login from one linux system to another. You would be using the same steps using cygwin on windows. My instructions are here:
http://geekswing.com/geek/unix/how-to-ssh-login-without-a-password-using-ssh-keygen-quick-tutorial/
Storing session settings in WinSCP GUI and trying to access them from WinSCP script running in SSIS is generally a bad idea. I believe there's no example or guide on WinSCP site that would suggest doing that.
WinSCP stores its configuration in registry in HKEY_CURRENT_USER hive. The SSIS typically runs under a dedicated system account, that have its own HKEY_CURRENT_USER hive, and won't see the GUI configuration.
For details see WinSCP FAQ about your problem:
https://winscp.net/eng/docs/faq_scheduler
The best you can do is isolate your your script from configuration by using the session URL with the open command, instead of the stored site name.
See also https://winscp.net/eng/docs/scripting#configuration
Your actual problem can be completely different though. But that's hard to guess as you have not shared any details, such as error message, log file, etc.