I can answer the question reflected in the title (which is slightly different from the post itself) but I’d guess a user might look here for both. For easier ssh, a trick I use for our Stanford clusters, along with a script that can help you to set it up. If you look in the “hosts” folder of the forward tool here, you’ll see simple scripts to set up a configuration.
Where does a configuration go?
You have a folder,
.ssh in your $HOME that is like a safe keeping bucket for credentials. This is where you could find public and private keys, along with a file called
~/.ssh/config where you can write named configurations for each resource you connect to.
How can I generate one?
For example, let’s look at this script for the Sherlock cluster.
Make it executable
chmod u+x sherlock_ssh.sh
And run it. The one thing it will ask us for is our username:
Sherlock username > pancake
You’ll see it spits out the configuration to the command line after I enter my username, so the portion from the top at “Host: sherlock” to the bottom you would want to add to
~/.ssh/config. If that file doesn’t even exist for you, then you can just pipe into it directly.
/bin/bash sherlock_ssh.sh > ~/.ssh/config
What do the components mean?
As mentioned in other threads, the configuration itself is going to vary based on your cluster! For example, sherlock has (or at the time of the writing has) 8 login nodes. So the script itself starts by selecting a random number between 1 and 8, and that becomes your node. The reason I chose to do this is so I can issue multiple commands in a row but only need to authenticate for one session from a terminal. Here is what the script looks like:
# Sherlock cluster at Stanford
# Prints an ssh configuration for the user, selecting a login node at random
# Sample usage: bash sherlock_ssh.sh
read -p "Sherlock username > " USERNAME
# Randomly select login node from 1..4
LOGIN_NODE=$((1 + RANDOM % 8))
echo "Host sherlock
The Control* and GSSAPI* parameters (perhaps someone can add more comment on these) help with enduring the session and also security, and tis would vary based on your cluster. I would also do a good search for ssh configurations and look at all the cool things you can set up!
How do I use it?
Once it’s set up, the cool part is you can interact with your resource just via the host name, the first name (Host: sherlock). So for example, I can issue commands in a row (and only need to authenticate for the first one).
$ ssh sherlock ls
$ ssh sherlock "ls SCRIPT"
How do I have multiple?
Have multiple just comes down to adding another (named) host in the file! For example: