New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Question...
Hey there;
I was looking into making SSH access slightly easier between some VPS's I have, and instead of having a hostname of chrisvps1.chriseaston.info or xxx.xxx.xxx.xxx; Is there a simple way of just having server 1 be able to connect to server 2 by just saying "ssh root@server2" instead of an IP or long hostname?
I might be missing something here; help?
Comments
Yes
Add it to /etc/hosts
xxx.xxx.xxx.xxx server2
I thin you can put it on /etc/hosts
oh lol.
I feel like such a fool now :']
or just set up an alias in .bashrc
alias ssh-server1='ssh -p 1234 [email protected]'
Oh, that's even better, as in, .bashrc in ~/.bashrc ?
Since most of my servers are operating on random ports.
exactly
Wow.
So I can also use aliases for other things too, like I could setup one which does a certain long command like "io" could then do a "dd" test?
Use an SSH config file under ~/.ssh/
'shortname' will appear in your SSH tab list.
I use separate keys for various servers so it suits me to use 'IdentitiesOnly' but you can always omit it (including the 'IdentityFile' directive)
yes;
alias io='dd if=/dev/zero of=test bs=64k count=16k conv=fdatasync && rm test'
alias has a lot of uses,for example i have an alias set for gst='git status', it's great for those often typed commands
effectively speaking @u4ia I could do
alias rsync-chris='rsync --verbose --progress --compress --rsh='ssh -p xxx' /home/chris/http/hosts/chriseaston.info/* 128mb:/home/backup/chriseaston.info/'
and that would effectively backup my /chriseaston.info/ folder and xfer it to my other server? just by typing "rsync-chris"?
Seems impossibruuu!
No, you need to escape some stuff
I think it has to be
alias rsync-chris='rsync --verbose --progress --compress --rsh=\'ssh -p xxx\' /home/chris/http/hosts/chriseaston.info/* 128mb:/home/backup/chriseaston.info/'
And maybe one more \ before the *
Why would you have to escape things? @gsrdgrdghd
http://en.wikipedia.org/wiki/Escape_character#Programming_and_data_formats
In this example bash would interpret the first ' (the one after
--rsh=
) as the matching ' that ends your alias.Ooooh... Right, I see lol! Thanks for that mate.
Nothing is impossibruuu!
add chriseaston.info to the search path in /etc/resolv.conf then you don't have to add individual hosts to the hosts file.
Oh, so I can just then do my128 since it's a subdomain of chriseaston.info?
There's always Bash...
Set an alias...
alias ssh2="/path/to/ssh2.sh"
Try it...
[me@home] ssh2 vps1
This way you don't have to keep modifying your hosts file or your aliases every time you get another vps