OSX Terminal Niceties for Remote Servers
I have absolutely no idea what to title this as — and frankly, its more for me than anyone else. I need a place to store this before I forget and go racking my brain 2 years from now on how to do this.
If you think you’re interested — this post is about the following:
- How to get your current user/directory in the title of terminal (iTerm.app for this post — same applies for Terminal.app though)
- How to make the backspace/delete keys work properly in nano/pico on local and remote servers
- Update your current user/path in the title when you SSH into a remote machine
- And how to setup password-less SSH, just because its on topic
.bashrc modifications
Making Terminal.app’s title update to the current user & path for both local and remote servers while letting the backspace and delete key work properly — all in one solution!
Add the following lines to both your local & remote .bashrc
# this is what updates your Terminal's title -- you can of course modify this
# but im not explaining how -- google it
export PROMPT_COMMAND='echo -ne "\\033]0;${USER}:${PWD}\\007"'
# this will make OSXs backspace & delete keys work properly
# in nano & pico
export TERM=xterm
stty erase ^H
# fancy prompt you say?
# again -- google for more info on this
export PS1="\\[\\033[0;34m\\][\\!]\[\\033[0;32m\\][\\u.\\h: \\w]\[\\033[0;32m\\]\\$\\[\\033[0m\\] "
#gives you something like:
# [0][rob.hades: ~]$ echo 'hello world!'
Now lets bind our servers for SSH so we don’t need passwords
Passwords are annoying — especially when you are using scp and rsync a lot.
Here is a very simple way to drop those passwords and have SSH do all the work.
In your terminal app (Locally)
Make your .ssh directory
$>mkdir -p ~/.ssh && cd ~/.ssh
Generate yourself some keys
~/.ssh $>ssh-keygen -t dsa -f ~/.ssh/id_dsa
Copy your public key to your remote server (Make sure the remote server has a ~/.ssh directory as well!)
~/.ssh $>scp id_dsa.pub {user}@{remoteserver}:.ssh
In the remote computer
Add that public key to your authorized_keys file for SSH
$>cd .ssh && cat id_dsa.pub >> authorized_keys2
Cleanup those files and make sure the authorized_keys file is set to the right perms.
~/.ssh $>chmod 640 authorized_keys2 && rm id_dsa.pub
That should make your life a bit more convenient







Add Yours
YOU