How to connect to your Amazon Instance? Redirected from cloud/how to connect to your amazon instance

    What is SSH?

    SSH stands for Secure Shell Handler and is a protocol used to connect securely to a remote server and execute commands. It is the equivalent of opening a terminal window on the remote server. To connect to a BitNami hosted server, you will need a special file named "Private Key", that is associated with your Amazon EC2. 

    What is an SSH Private Key?

    Each Amazon cloud account has an associated SSH key file ("Private key") that you can use to connect remotely to the servers launched using that cloud account credentials. This file needs to be protected, as anybody who has access to it can access your servers. On Linux and OS X, it is necessary to change its permissions, so it is only readable by you.

    $ chmod 600 bitnami-hosting.pem
    

    Otherwise you may get a 'bad permissions: ignore key' error.

    How can I download my private SSH key from the BitNami Hosting Control Panel?

    You can download his file going to Clouds > Manage, clicking on the appropriate cloud account, then on the 'Download Key' button and select the appropriate format: 

    • Select PEM format if you are going to connect from Linux, OS X or other Unix systems
    • Select PPK for Windows Putty, FileZilla and WinSCP. 

    How can I download my private SSH key from Amazon EC2 Control Panel?

    It is not possible to download the SSH key from the Amazon EC2 Control Panel once it has been created. If you launched your server using the Amazon EC2 Control Panel and selected the option to generate a new key pair, it would have been available for download at that time.

    How can I get my private SSH key in PPK format?

    PPK is the private key format used by Putty, FileZilla and WinSCP. If you are a BitNami Cloud Hosting client, you can download your key in this format directly: click "Connect" in "Server Manage" view and use "PPK" button. Otherwise, you will need to convert your downloaded key to PPK format as described here: http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter8.html#puttygen-conversions

     putty-download.png 

    putty-conversion.png  putty-conversion2.png

    How can I use SSH to connect to my server on Linux or Mac OS X?

    Linux and Mac OS X come bundled with SSH clients by default. To connect to your server using SSH, you need to open a Terminal and type the following:

    $ ssh -i bitnami-hosting.pem bitnami@example.com
    

    You will need to replace bitnami-hosting.pem with the path to your private key file and replace example.com with the IP address or hostname of your server.  You can find out the hostname of a server by going to the Servers page, selecting the server and clicking 'Manage Server'. The hostname will appear next to Public DNS and it will be similar to 'ec2-xyz.compute-1.amazonaws.com'. Of course a server needs to be running so you can connect to it.

    Make sure your SSH key bitnami-hosting.pem has proper permissions. You can set the permissions using the command below:

    $ chmod 600 bitnami-hosting.pem
    

    How can I access my server as the root user?

    By default, you can only log in as the 'bitnami' user to a BitNami EC2 instance. Once logged in, you can use the 'sudo' utility to become the super user or execute.

    $ sudo su
    

    How can use SSH to connect to my server on Windows?

    • Putty

    Windows does not come with a bundled SSH client by default. It is recommended that you use the freely available Putty utility, which can be downloaded from:

    http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

    You will need to get your SSH key in PPK format: http://wiki.bitnami.org/cloud/how_to_connect_to_your_amazon_instance#How_can_I_get_my_private_SSH_key_in_PPK_format.3f

    Once you have your key in PPK format, you can connect following this steps: 

    1. Start "Pageant" ( Start Menu -> Programs -> Putty -> Pageant ).
    2. Click "Add key" and choose the PPK file.
    3. Open "Putty" application ( Start Menu -> Programs -> Putty -> Putty ).
    4. Go to Connection -> Data using the left menu.
    5. Enter "bitnami" as the "Auto-login username".
    6. Go to "Session".
    7. Insert your server Public DNS (ec2-xyz.compute-1.amazonaws.com / xyz.bitnamiapp.com) in the "Host Name" field. You can find this in Server Management for BitNami Cloud Hosting servers or in the instance properties in Amazon console. 
    8. Click "Open" to start the SSH session.

    If you prefer to use putty from the command line you should include '-i' and '-l' options as follows:

    > putty -i "C:\Path\To\bitnami-hosting.ppk" -l bitnami example.com

    Where you will need to replace example.com with the IP address or hostname of your server.  You can find out the hostname of a server by going to the Servers page, selecting the server and clicking 'Manage Server'. The hostname will appear next to Public DNS and it will be similar to 'ec2-xyz.compute-1.amazonaws.com'. Of course a server needs to be running so you can connect to it. 

    • MobaXterm

    MobaXTerm is an enhanced terminal with an X server and a set of Unix commands (GNU/Cygwin) packaged in a single portable exe file. You can dowload it at:

    http://mobaxterm.mobatek.net

    In this case it is not necessary to import your private key, you can use it directly.

            

    You can copy files to the machine using the right panel or you can connect to the machine through SSH:

    $ ssh -i private_key bitnami@your-machine-hostname
    

    How to give SSH access to the another person or your customer ?

    It is better if you ask your customer to send you his own public ssh key generated on Linux/Unix/OS X, this way you can give him an access to your machine without sharing your private keys.
    Copy this file my_customer_public_ssh_key to your server.

    Now you have two options:

    • you can create a separate account for him (RECOMMENDED)
    • or just allow him to log into the server using the 'bitnami' account
    Create a separate account

    Add myadmin account and set the password:

    $ sudo adduser --ingroup admin myadmin
    Adding user `myadmin' ...
    Adding new user `myadmin' (1004) with group `admin' ...
    Creating home directory `/home/myadmin' ...
    ...
    $ sudo mkdir /home/myadmin/.ssh
    $ sudo cp ~/my_customer_public_ssh_key /home/myadmin/.ssh/authorized_keys
    $ sudo chown -R myadmin:admin /home/myadmin
    $ sudo chmod 600 /home/myadmin/.ssh/authorized_keys
    

    Right now your customer can login as 'myadmin' user using his own ssh key and use 'sudo' with password set above.

    Use the 'bitnami' account

    Backup your old authorized_keys:

    $ cp /home/bitnami/.ssh/authorized_keys /home/bitnami/.ssh/authorized_keys.bak

    Add your customer key to authorized_keys (PLEASE BE EXTREMELY CAREFUL to avoid losing ssh access at all)

    $ cat ~/my_customer_public_ssh_key >> /home/bitnami/.ssh/authorized_keys
    

    Now you both are able to access the machine.

    You can revert the changes by removing the last line from the /home/bitnami/.ssh/authorized_keys file or by restoring the old authorized_keys file:

    $ cp /home/bitnami/.ssh/authorized_keys.bak /home/bitnami/.ssh/authorized_keys

    Does BitNami Hosting provide a way of setting up DNS so regular domain names can be set to point to the AWS url?

    BitNami Hosting launches instances with a dynamic IP by default, which means that the IP address changes after you stop and restart the machine. In many cases, this is not desired and instead you want to assign a specific IP address (also known in EC2 as ‘elastic IP’). To do so, go to the ‘Manage’ section, click ‘Assign IP’ and choose one of the already available IP addresses or select ‘Newly created static IP’ to create a new one. Then, click ‘Confirm’. Your machine should be accessible with the new IP, though it may take a a few minutes.

    You can point an existing domain name to a dynamic or static IP address. To do so, go to your DNS provider management console and point the domain name to the BitNami Hosting machine IP. It may take some time before all DNS servers refresh the new domain location.  We do not currently allow creating or managing domain names from the BitNami Hosting interface yet.

    How to connect to the BitNami MySQL remotely?

    Currently it is not possible to connect remotely to the machine port 3306. The default AWS Security Group does not allow it. However you can do the following:

    • Navicat configuration

    - In the connection properties set the following values
    - The latest version of Navicat supports setting up a ssh tunnel automatically.

    Host Name: localhost
    Port: 3306
    User Name: root
    Password:<set during machine build>

    - Then click SSH tab.
    - Mark “Use SSH Tunnel”
    - Enter the following values:

    Host Name: ec2-your-machine
    Port: 22
    User Name: bitnami
    Authentication Method: Public key
    Private Key: your-key-dir/bitnami-hosting.pem

    • Generic solution - it should work with default MySQL client

    Set up the ssh tunnel. This will set up the ssh tunnel and remote MySQL will be available via localhost:33306. You can also use Putty to run the command on Windows.

    $ ssh -v -N -L 33306:localhost:3306 -i your-key-dir/bitnami-hosting.pem bitnami@ec2-your-machine
    

      

    You can test it now in the another terminal window:
    $ mysql -h localhost -P33306 -u root -p --protocol=tcp
    
    - You can configure any other MySQL client program in the following way:
    - port: 33306
    - hostname: localhost
    - login: root
    - password: <set during machine build>

    How to enable phpMyAdmin or phpPgAdmin to be accessed remotely securely through SSH?

    By default phpMyAdmin and phpPgAdmin are not accessible from the outside for security reasons. In order to access them, you can create a SSH tunnel to Apache, sending your requests to your webserver from 127.0.0.1 (localhost). 

    You should follow these steps to create the tunnel:

    1. Get your SSH private key if you don't have it already. More info: http://wiki.bitnami.org/cloud/how_to_connect_to_your_amazon_instance

    2. Create the tunnel.

    - If you are in Linux or Mac you can run the following in a console in your local machine (using your Public DNS instead of xyz.bitnamiapp.com):

    $ ssh -N -L 8888:127.0.0.1:80 -i bitnami-hosting.pem bitnami@xyz.bitnamiapp.com
    

    - If you are using Windows, you can use Putty:

    3. While the tunnel is active you can connect to the web application at http://127.0.0.1:8888/phpmyadmin or http://127.0.0.1:8888/phppgadmin in your browser. The default login is:

    • username: root ("administrator" for legacy versions) for MySQL or postgres for PostgreSQL database.
    • password: bitnami (for BitNami AMIs), <application password> (for BitNami Cloud Hosting)

    Take a look at this link about how to get your application password for BCH servers

    How to configure Dreamweaver to access server files through a SSH tunnel?

    Dreamweaver does not support SFTP connections with a private key. If you want to access to your BitNami Amazon EC2 server through FTP, you can create a SSH tunnel for FTP connections, sending your requests to your webserver from localhost.

    You should follow the following steps to create the tunnel:

    Server
    Host: ec2-xx-yy-zz.compute-1.amazonaws.com
    Port: 22
    
    Authentication
      user: bitnami
      Use keypair manager: Add your SSH private key 
      (not necessary to convert into ppk format)
    
    Services
     FTP-to-SFTP bridge
       Listen insterface: 127.0.0.1
       Port: 21
    

    • Once you have created the tunnel, you can go to Dreamweaver to configure the server connection.
    • Go to Dreamweaver -> Site -> Manage Sites -> New site -> Servers -> New server
    Connect using: FTP
    FTP address: localhost  Port: 21
    Username: bitnami
    Password: the same password that you set in the server machine for bitnami.
    

     

    If you did not set a password for the bitnami user, you can log in the machine through SSH and run the following command:
    $ sudo passwd bitnami

     

    • You can test now the FTP connection to your server.

    Comments

    You must login to post a comment.