Tuesday, January 22, 2008

Let's start with a few basic SSH commands

Secure Shell or SSH is a network protocol that allows data to be exchanged over a secure channel between two computers. Encryption provides confidentiality and integrity of data. SSH uses public-key cryptography to authenticate the remote computer and allow the remote computer to authenticate the user, if necessary.

SSH is typically used to log into a remote machine and execute commands, but it also supports tunneling, forwarding arbitrary TCP ports and X11 connections; it can transfer files using the associated SFTP or SCP protocols.

An SSH server, by default, listens on the standard TCP port 22. So thats the port you should keep open to allow incoming SSH requests.

Tools :

I usually use Win SCP or Putty when using from Windows or the inbuilt SSH client in Linux.

Here are a few common SSH commands :

1. ls -al : Lists all files & Directories in current folder with their attributes

2. chmod : Change Permissions on file/folder

The set of 3 go in this order from left to right:

0 = --- No permission
1 = --X Execute only
2 = -W- Write only
3 = -WX Write and execute
4 = R-- Read only
5 = R-X Read and execute
6 = RW- Read and write
7 = RWX Read, write and execute

chmod numberpermissions filename

3. chown : change file/ folder ownership

chown username folder/filename : changes ownership to username
chown username.groupname folder/filename:changes ownership to username, group to groupname
4. cd : change directory

5.tar Used for creating and extracting .tar.gz and .tar files
tar -zxvf file.tar.gz : Extracts the file
tar -xvf file.tar : Extracts the file
tar -cf archive.tar contents/ : Takes everything from contents/ and puts it into archive.tar

ZIP Files: Extracting .zip files shell command
unzip file.zip

No comments: