Logo Background RSS

» ssh

  • SSH slow login Problem
    By on January 31st, 2009 | 1 Comment1 Comment Comments

    SSH slow  login? Disable reverse DNS lookup

    when you log into the SSH server, it will do a reverse DNS lookup of the client for security reasons. Thats why it takes a time to login.

    vi /etc/ssh/sshd_config (and add the below line:)

    UseDNS no

    
    

    So enjoy SSH :D

  • Using SSH by Putty
    By on December 12th, 2008 | 1 Comment1 Comment Comments

    Putty is a free software application for Windows 95,98, XP, & Vista which can be used to make a SSH Connection. You can find the application at Click here

    http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

    1. Download it on your pc.
    2. Double-click on the putty.exe program to open.
    3. Next fill in the appropriate SSH settings for your service:
    Putty

    Putty

    Next fill in the appropriate SSH settings for your service:

    Host Name:

      • Host name

        Host name

        • (gs) Grid-Service – s#####.gridserver.com or mt-example.com
        • (dv) Dedicated-Virtual -mt-example.com or xxx.xxx.xxx.xxx
        • (ss) Shared-Server – mt-example.com or xxx.xxx.xxx.xxx
      • Port: 22
        port 22

        port 22

      • Connection Type: SSH

        Connection Type

        Connection Type

      • Next click Open to start the SSH Connection:

      putty open

      putty open

      Once the SSH Connection is open you should see a terminal prompt saying login as: Please provide your full username:

    Login

    Login Screen

      • (gs) Grid-Service – The default should be serveradmin@mt-example.com, however you may also login as username@mt-example.com.

        NOTE:

        Please make sure SSH is enabled for the user. SSH can be enabled from within the (ac) AccountCenter.

      • (dv) Dedicated-Virtual – You may login as the root user, or as a domain’s FTP user which has SSH access enabled
      • Next provide your password. Please note that you will not see any typing such as *** when providing your password. Once you hit enter you should now be connected to your service.

      Common SSH Command

  • How to use SSH Via HTTP Proxy using Corkscrew in Ubuntu
    By on October 30th, 2008 | 1 Comment1 Comment Comments

    If you want to ssh your vps server or your home computer from your work place (assuming you are using http proxy).You need to use Corkscrew.

    corkscrew is a simple tool to tunnel TCP connections through an HTTP proxy supporting the CONNECT method. It reads stdin and writes to stdout during the connection, just like netcat.

    It can be used for instance to connect to an SSH server running on a remote 443 port through a strict HTTPS proxy.

    Install corkscrew in ubuntu using the following command

    sudo aptitude install corkscrew

    This will complete the installation.

    Configue corkscrew

    If your HTTP proxy uses authentication, then you’ll need to tell it about the username and password to use This is where the concept of ‘auth-file’ comes into play. All you have to do is put your username & password, separated by a colon, into a textfile. Once you’ve done this, you just have to tell corkscrew where to find the auth-file. Create a file called .corkscrew-auth in your home directory

    $touch .corkscrew-auth

    $gedit .corkscrew-auth

    and place your username and password in the following format

    username:password

    Save and exit the file.

    Configure ssh For Tunneling

    Now we’ll tell ssh what to do when connecting to all or specific hosts. Open up ~/.ssh/config (that’s /home/yourusername/.ssh/config) in your favourite text editor (gedit,nano,vim etc)

    $gedit /home/yourusername/.ssh/config

    and add the following lines

    Host *

    ProxyCommand corkscrew proxyhostname proxyport %h %p /home/username/.corkscrew-auth

    Save and exit the file

    Note: replace proxyhostname and proxyport with the equivalents for your network.

    Note: you won’t need to add the last section, ‘/home/username/.corkscrew-auth’, if your HTTP proxy doesn’t use authentication.

    What we’ve just told ssh to do is for all hostnames (’Host *’), use the following proxy command to route the connection.If you want more secure connections you can also list of hosts.

    Corkscrew Syntax

    corkscrew proxy proxyport targethost targetport [ authfile ]

    proxy – This is the name of the host running the HTTP proxy.

    proxyport – This is the port on which to connect on the proxy.

    target – This is the host to reach through the proxy.

    targetport – This is the port to connect to on the target host.

    Test your SSH connection

    ssh serverip

  • Common SSH Commands
    By on September 17th, 2008 | 3 Comments3 Comments Comments

    This is a list of Common commands that can be run from root / SSH access.

    I. Basic Commands

    A. Retrieve Plesk Admin Password

    cat /etc/psa/.psa.shadow

    B. Change Directory (cd)

    cd /path/to/directory/

    C. Listing Files/SubFolders (ls)

    ls -alh

    (files and subfolders listed with perms in human-readable sizes)

    D. Checking Processes

    ps -a top -c

    (process viewer – Ctrl+C to exit)

    ps -auxf

    (process list)

    E. Start/Stop Services

    /etc/init.d/<service> start|stop|restart|status

    (“/etc/init.d/httpd stop” stops apache)

    F. Check Bean Counters (hard and soft limits, failcounts, etc.)

    cat /proc/user_beancounters

    II. File System Commands (df & du are (dv)-only commands)

    A. Check Total Disk Usage

    df

    (gives physical disk usage report with % used)

    B. List Files/Folders +Sizes (du)

    du

    (lists all filesizes. This will take some time.)

    du -sh

    (lists all the subfolders/sizes in a dir)

    C. Remove/Delete Files (rm /path/to/filename.htm) -DANGER- always verify

    rm -vf

    (force-deletes file. Dont run unless you know EXACTLY what you’re doing)

    rm -vrf

    (force deletes folder and all subfolders and files)

    To Remove a Directory you can use the following command:

     rmdir  

    D. Copy Files (cp)

    cp filename.abc /new/path/filename.abc.123
    

    E. Move Files (mv)

    mv filename.abc /new/path/filename.abc.123
    

    F. Create Empty File (touch)

    touch filename.123

    III. File Permissions and Ownership

    A. Change Permissions of files (chmod)

    chmod 000 filename.abc

    (defaults are usually 755 for folders, 644 for files)

    TIP:

    1st digit=Owner; 2nd=Group; 3rd=Other
    (-rwxrwxwrx = 777, -rwxr-xr-x = 755, -rw-r–r– = 644, etc.)
    7 = Read + Write + Execute
    6 = Read + Write
    5 = Read + Execute
    4 = Read
    3 = Write + Execute
    2 = Write
    1 = Execute
    0 = All access denied

    B. Change Ownership of files (chmown)

    chown user:group filename.abc

    (you can see user and group w/ ls -alh)

    TIP:

    Anytime a user creates a file, the Ownership of the file matches that user. In Plesk, every domain that has hosting has a different user. So if you are copying files from one domain to another, you must remember to change ownership.

    IV. Checking Log Files (dv)

    Log files can tell you a lot about whats going on on a (dv). You can use the command:
    ‘tail -n 100′ before the logfile name to list the last 100 entries of the logfile.

    Here are some of the most common:

    A. Main Error Log

    /var/log/messages

    B. Apache Error Log

    /var/log/httpd/error_log

    (main)

    /home/httpd/vhosts/mt-example.com/statistics/logs/error_log

    (per-domain) (May also be: /var/www/vhosts on newer dvs)

    C. MySQL Logs

    /var/log/MySQLd.log
    

    D. Mail Logs

    /usr/local/psa/var/log/maillog

    NOTE:

    Common issues to look out for in log files

    • The main error log will not always give you all the information you want for a svc.
    • You may see alot of failed SSH and FTP connections, that is generally normal.
    • Keep an eye out for MaxClients errors in the Apache logs if a customer is complaining of Apache dying alot. You can check the KB for raising MaxClients settings.
    • If a customer does not set up Log Rotation for a domain under Plesk, then Log Files will build up and may take up alot of unneeded space. You can usually delete old log files in Plesk, and change the Log Rotation to Daily instead of by size.
    • MailLogs can show you if a customer is spamming, or if mail is coming in or out.
    • MySQL Logs should be able to show you general MySQL errors such as bad connections, or corrupted tables. Check the Int. KB for the ‘myisamchk -r’ repair table command.

    V. Advanced Commands

    A. Find. You can do alot with find. for now lets find all files over 10MB.

    cd /
    find / -type f -size +10000k -exec ls -lh {} \; | awk '{ print $5 ": " $9 }' |sort -n
    

    B. Grep. Another handy tool to get specific information

    cat file | grep blah

    (only lists the information where the word blah is found)

    C. Less/More

    less filename.abc 

    (displays the content of a file. arrows to scroll, ‘q’ to quit.)

    more == same thing basically. You can use the ‘| more’ command to scroll through something page or line at a time.

    tail -n 1000 /var/log/httpd/error_log | more

    VI. Vi is a basic text editor.

    Careful what keys you hit while in vi.

    vi /path/to/filename.abc

    TIP:

    You can learn more about using the VI/VIM text editor by reading the following guide: