Archive for the ‘ssh’ Category

Persistent SSH sessions

Thursday, March 13th, 2008

The screen program, among other useful things, lets you keep an SSH session running even after you disconnect from SSH. Here’s how to use it.

SSH in.

ssh user@hostname.com

Once on the remote machine, set up a named screen:

screen -S myscreen

In another terminal, open another SSH connnection and start another screen:

screen -S mysecondscreen

You can see they are there by using, in either of the terminals,

screen -ls

This does NOT start screen, just lists the different screens.

You can now disconnect the SSH connections. When you reconnect, you can use

screen -r myscreen

or

screen -r mysecondscreen

to reconnect to the one you want.

A more secure SSH configuration

Thursday, March 13th, 2008

Some easy ways to configure SSH to be a little more secure:

Edit /etc/ssh/sshd_config as root.

  • Change the port (default is 22)
  • Change “PermitRootLogin yes” to “PermitRootLogin no”
  • AddUser username
  • save and quit
  • restart the ssh server: sudo /etc/init.d/ssh restart

More info here:
http://ubuntu-tutorials.com/2007/02/14/what-you-ought-to-know-about-securing-ssh/

SSH: Add public key to remote server

Thursday, March 13th, 2008

Easy way to add public key of this machine to a remote machine:

ssh-copy-id -i ~/.ssh/id_dsa.pub root@fileserver01

More good info here:
http://ubuntu-tutorials.com/2007/02/05/unattended-ssh-login-public-key-ssh-authorization-ssh-automatic-login/

Configure SSH

Wednesday, January 9th, 2008
sudo vim /etc/ssh/sshd_config 

Restart SSH

Wednesday, January 9th, 2008
sudo /etc/init.d/ssh restart

Check SSH login attempts

Monday, December 10th, 2007
cat /var/log/auth.log | grep sshd

To check the zipped ones, use

zcat /var/log/auth.log.1.gz | grep sshd