Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Tuesday, August 13, 2013

Managing SSH keys

I found a GREAT post on dealing with multiple SSH keys. This makes it much easier to securely use mulitple keys so a compromised systems doesn't compromise multiple servers.
In essence, you create a "config" file in .ssh and tell SSH what private key to use based on the name of the host you are SSHing to. You can also specify user and port. I also found you can specify multiple hosts as "Host abc or xyz"

~/.ssh/config
Host *.home.lan
  IdentityFile ~/.ssh/id_dsa.home
  User kbsingh

Host *.vpn
  IdentityFile ~/.ssh/id_rsa.work
  User karanbir
  Port 44787

Host *.d0.karan.org
  IdentityFile ~/.ssh/id_rsa.d0
  User admin
  Port 21871

I added aliases to my /etc/hosts file so I could differentiate between SSH running on mulitple ports at the same server (VM Server). Now I can SSH by the alias name from the hosts file and I don't have to specify the port number or user.

Friday, July 26, 2013

Using the Linux screen command to detach processes from terminal

A nice simple example based page on how to use the screen command in Linux.

http://www.thegeekstuff.com/2010/07/screen-command-examples/

Allows you to detach and later re-attach to SSH sessions without killing your processes.

Start screen session.
$ screen ./work_on_something.sh
Press CTRL+A and then "d" to detach.

List screen sessions.
$ screen -ls
There is a screen on:
21952.pts-0.debian-7 (07/26/13 23:25:29) (Attached)
1 Socket in /var/run/screen/S-user.

If detached, attach with -r
$ screen -r 21952.pts-0.debian-7

Thursday, February 7, 2013

Fixing slow SSH logins

I've noticed recently that logging in to my server over SSH has a delay of 5 to 10 seconds, which gets irritating. The problem has to do with SSHD trying to resolve IP addresses of incoming connections. Add "UseDNS no" to sshd's config file and it all goes away.

# echo "UseDNS no" >> /etc/ssh/sshd_config
Restart your DNS server and it should log in instantly.