Tuesday, August 31, 2010

Mounting Samba drive in Linux

Samba allows file and print sharing between computers running Windows and computers running Unix.
Samba sets up network shares for chosen Unix directories (including all contained subdirectories). These appear to Microsoft Windows users as normal Windows folders accessible via the network. Unix users can either mount the shares directly as part of their file structure using the smbmount command OR can use a command line utility, smbclient (libsmb) installed with Samba to read the shares.


Fedora/RH linux
  uses Common Internet File System (CIFS)
yum search cifs
yum install cifs-utils.i686 samba4.i686
sudo mount.cifs //172.1.1.1/dir /mnt/win-dir -o username=myuser


Ubuntu
  uses smbfs
sudo apt-get install smbfs
sudo mount -t smbfs //172.1.1.1/dir /mnt/win-dir -o username=myuser


  Another utility is smbmount
sudo smbmount //172.1.1.1/dir /mnt/win-dir -o username=myuser

Thursday, August 19, 2010

"ssh-agent" - saves time while remote login

ssh-agent is a program that used together with Secured Shell programs (eg:OpenSSH) provides a secure way of storing the passphrase of the private key.

In order to login securely to a remote system via a secure shell, a private key/public key pair is generated. The private key is stored on the local machine. The public key is stored on the target machine in the $HOME/.ssh/authorized_keys file. Public keys are not sensitive information and may be known to anybody, whereas the private key needs to be protected very carefully by a strong passphrase. Using multiple servers is easier by using ssh agent. ssh-agent remembers the passphrase so that the user does not need to type it every time he or she wants to connect or send data to the server.

Create the identiy-key pair:
cd ~/.ssh
ssh-keygen

Copy the public key to the remote server:
scp ~/.ssh/id_rsa.pub user@remote.host:pubkey.txt
ssh user@remote.host
mkdir ~/.ssh
chmod 700 .ssh
cat pubkey.txt >> ~/.ssh/authorized_keys
rm ~/pubkey.txt
chmod 600 ~/.ssh/*
exit

Test the remote public key:
ssh user@remote.host

exit

Start the ssh-agent:
eval 'ssh-agent'

Add your private key to the agent's cache:
ssh-add

Test the connection again:
ssh user@remote.host
exit