Using the ~/.ssh/config file is an easy way to give your
remote machines nicknames and reduce the number of keystrokes needed
to login with ssh, rsync,
hg push/pull/clone, access
files via Emacs Tramp
(Transparent Remote (file) Access, Multiple Protocol),
or use any other SSH-based tool.
Here is part of my ~/.ssh/config file. It defines the
nicknames turk, tyran, tuna, and tally for some EC2 servers I've been
working with.
Host turk User root HostName ec2-67-202-21-122.compute-1.amazonaws.com Host tuna User root HostName ec2-75-101-178-62.compute-1.amazonaws.com Host tyran User root HostName ec2-67-202-43-207.compute-1.amazonaws.com Host tally User root HostName ec2-67-202-59-207.compute-1.amazonaws.com
Now, wherever I would normally have typed
root@ec2-67-202-21-122.compute-1.amazonaws.com,
I can just type turk. Here are some examples.
Old way:
ssh root@ec2-67-202-21-122.compute-1.amazonaws.com
New way:
ssh turk
Old way:
rsync -avz myproject root@ec2-67-202-21-122.compute-1.amazonaws.com:/srv
New way:
rsync -avz myproject turk:/srv
Old way:
hg push ssh://root@ec2-67-202-21-122.compute-1.amazonaws.com//srv/myproject
New way:
hg push ssh://turk//srv/myproject
To use your ~/.ssh/config with Emacs Tramp, you will need
something like the following in your .emacs:
(tramp-set-completion-function "ssh"
'((tramp-parse-sconfig "/etc/ssh_config")
(tramp-parse-sconfig "~/.ssh/config")))
Old way:
C-x C-f /root@ec2-67-202-21-122.compute-1.amazonaws.com:/srv/myproject/myfile.py
New way:
C-x C-f /turk:/srv/myproject/myfile.py
Old way:
scp etc/.screenrc root@ec2-67-202-21-122.compute-1.amazonaws.com:/root
New way:
scp etc/.screenrc turk:/root
Pretty cool, eh? You can also specify the Port,
CompressionLevel, and many other ssh settings.
See the ssh_config(5) manpage for more information.
aws
(4)
bison_flex
(1)
blogger
(4)
c
(10)
cardstore
(5)
colinux
(2)
concurrency
(8)
conkeror
(2)
cygwin
(17)
dell
(3)
django
(31)
eclipse
(30)
emacs
(18)
email
(1)
error
(11)
gnip
(1)
json
(1)
keyboard
(3)
linux
(31)
matplotlib
(5)
mercurial
(3)
openid
(1)
personal
(4)
preferences
(4)
pyqt
(18)
python
(88)
rails
(1)
ratpoison
(3)
recursion
(1)
rsync
(3)
ruby
(2)
sql
(10)
subversion
(4)
twisted
(5)
ubuntu
(33)
untagged
(7)
urxvt
(3)
vxworks
(26)
wmii
(3)