Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Yet another method of creating SSH shortcuts Network
There are a a number of hints here providing ways to create *.inetloc-based shortcuts for remote connections via SSH (secure shell), but these don't really allow ssh://user@site.com addresses or alternate ports (a must if the SSH server is internet-facing). The following method enhances the previous suggestions, and in addition, allows quick start of a session or scp from Terminal itself. For instance, rather than typing ssh -p 222 fred@web.host.com, you'll be able to type ssh web, or use the ssh:// hint to create a quick access icon in the Finder.

To start, open Terminal and type the following:
$ cd ~/.ssh
$ nano -w config
You will have a blank file where you can create a three- or four-line shortcut entry for each host in the form of:
host web
user fred
HostName web.host.com
port 222

host mail
user root
HostName mail.host.com
port 2000
Press Control-X then Y to save. Obviously, replace the relevant bits above with the information specific to your SSH connections. The port line is optional, for those servers not on port 22.

Now to test. In Terminal, type ssh web (or whatever you named it), and ssh should start, switch you to the alternate user and port, and place you at the login. Now you can follow the other hints -- start Text Edit and write ssh://web. Highlight this and drag it to your Desktop or a folder. Now clicking this shortcut will start Terminal with an ssh session using your pre-configured host, login name, and port information.

[robg adds: This worked as described for me.]
    •    
  • Currently 2.40 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[22,592 views]  

Yet another method of creating SSH shortcuts | 8 comments | Create New Account
Click here to return to the 'Yet another method of creating SSH shortcuts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Yet another method of reading man pages
Authored by: sapporo on Nov 28, '06 09:05:09AM
There are a number of hints here providing ways to read man pages, but these don't really allow reading the man page on a remote Unix box. The following method enhances the previous suggestions, and in addition, allows quick start of a session from any Unix shell.

To start, open a shell and type the following:

$ man NAME_OF_COMMAND

[ Reply to This | # ]

Yet another method of creating SSH shortcuts
Authored by: toppledwagon on Nov 28, '06 09:10:29AM
If you have a 'bastion' server that you have to hop through at work to get anywhere, here is an easy way to do that automatically:
Host bastion
  HostName bastion.example.com
  User username
  Port 222

Host *.example.com
  User username
  ProxyCommand ssh -q bastion "nc %h %p"
Now ssh to web001.example.com and it'll automatically bounce through bastion. This hint requires nc (aka netcat) on the bastion host. It also helps if your keys are setup correctly and you are forwarding your agent.

-Dave

[ Reply to This | # ]
Yet another method of creating SSH shortcuts
Authored by: Lutin on Nov 29, '06 06:48:40AM
To log from outside into my school, I have to go through the school ssh gate.
We're not allowed to execute anything on the gate - except a command that list all available machines.
To prevent forgotting to log on an "inside machine" I have an alias that log on the gate, then, using the command parameter of the ssh command, log me on an other machine.
I like this hint, because everything is down into one config file and don't pollute my alias.

So, assuming you want to connect to a machine named box1, I suppose you could simplify and edit your config file like this:
Host *.example.com
  User UserName
  ProxyCommand ssh -q box1
I doesn't require netcat. I can 't test it (I'm at work on a **** Windows PC) and will edit it tonight if required.

On an other side, with my alias, I could specify when excuting it, to which inside box I want to connect (in case of the hard coded one is down).
Would someone know a way to transform the config file to something along those lines?
Host (*).example.com
	User UserName
	ProxyCommand ssh -q \1


[ Reply to This | # ]
Yet another method of creating SSH shortcuts
Authored by: noworryz on Nov 28, '06 09:49:43AM

You can find information about the parameters in ~/.ssh/config by typing:


man 5 ssh_config

If you find you are being timed out by the remote host when you stop typing for a minute or two, you can add the following at the beginning of the file to send a "keep alive" signal over the link every thirty seconds for an hour:


  ServerAliveInterval 30
  ServerAliveCountMax 120

So that you don't continually get asked if the security key is OK, you can give SSH both the true name for the remote host and the name you are using for it (which will have to be different if you use it both remotely and locally):


Host mymacnameforhost
  HostName firewall.mycompany.com
  Port 2222
  HostKeyAlias truehostname    # name to use for ssl key check
  User myusername              # my name to use when logging on the remote host
  BatchMode yes                # use ssl key pair generated by ssh-keygen
  StrictHostKeyChecking no     # don't hassle me about keys

If a firewall guards the host, the Port number is the port number on the firewall that will get you through to the host and the HostName is the address of the firewall.

The BatchMode option says you never want to type your password and instead want to use a pair of key files; one stored on your Mac in ~/.ssh/id_dsa.pub and one stored on the remote host in ~/.ssh/id_dsa. For more information on key pairs, type:


man ssh-keygen
To generate a pair of keys, usually you will just have to type:

ssh-keygen -t dsa
then copy the two files to the right places, after manually logging on.

Note that NONE of the above applies to you if you can't log on by typing:


ssh -p portno myusername@hostname

where portno, myusername and hostname are as discussed above; i.e., the firewall port, your user name on the remote host and the IP address of the firewall. So try that first.

[ Reply to This | # ]

Yet another method of creating SSH shortcuts
Authored by: hibbelig on Nov 29, '06 01:28:25AM

Is it really necessary to turn off strict host key checking? It should only ask once for each remote host. When it asks, accept and store the remote host key. If it ever asks a second time about the same remote host, then you know that the remote host key has changed -- a possible security attack.



[ Reply to This | # ]
Yet another method of creating SSH shortcuts
Authored by: hibbelig on Nov 29, '06 01:33:22AM
Is it necessary to use BatchMode? When the keys are set up correctly, ssh doesn't ask for a password nor passphrase, regardless of the batch mode setting. If the keys aren't set up correctly, then my understanding is that batch mode makes the connection fail, whereas without batch mode one at least has a chance to enter the password/passphrase.

[ Reply to This | # ]
Yet another method of creating SSH shortcuts
Authored by: mkoistinen on Dec 03, '06 04:09:28AM
...but these don't really allow ssh://user@site.com addresses or alternate ports...
Er, wrong. Have you even tried it before asserting such a claim? I use this method every single day:

ssh://[username]@[server]:[port]
or, in your case: ssh://user@site.com:222

is what you're looking for and I have a folder full of these shortcuts in my dock for easy access. In addition, these are easy to move from one machine to another, if so desired.

[ Reply to This | # ]
Yet another method of creating SSH shortcuts
Authored by: legacyb4 on Dec 05, '06 08:04:17AM

Neat tip. Guess I'll have to play around and see how to incorporate SSH tunneling as part of this file.

---
[url=http://lumine.net]lumine.net[/url]



[ Reply to This | # ]