ssh feature - ignore colon in host name
Christian Iversen
chrivers at iversen-net.dk
Tue Feb 23 06:21:49 EST 2010
On 2010-02-19 12:21, Paul Mansfield wrote:
> sorry if this has been discussed and rejected before, I'm new to the
> list, I did google but didn't find anything.
> --
>
> quite often I use ssh and scp within a few minutes, so I might do this...
>
> scp myfile user at host.example.com:
> ssh user at host.example.com
>
> it would make life a lot easier if I could type
> scp myfile user at host.example.com:
> ssh !$
>
> or sometimes I simply copy too much and paste in host name and then have
> the faff of removing it. ok, that's a particularly bad example of being
> lazy :-)
>
> for the above to work, ssh would have to ignore the colon, that's all. I
> don't think the colon can have any significance in the hostname, so
> throwing it away wouldn't be harmful!?
>
> I could write a wrapper script, but I'm lazy, and figured it would be
> nicer if ssh could simply have this quick hack... please
This, as others have mentioned, does not belong in ssh.
However, you can very easily do this without creating a wrapper script.
Just add the following to your .zshrc (or rewrite for other shells):
function ssh()
{
/usr/bin/ssh $@[1,-2] ${@[-1]%:}
}
This will invoke (the real) ssh with all the positional arguments,
except ":" will be removed from the last argument, if present.
No extra files needed, no wrapper scripts, no measurable performance
hit, standard ssh software.
Better solution in my book :)
--
Med venlig hilsen
Christian Iversen
More information about the openssh-unix-dev
mailing list