# Linux Connect
There are two ways to connect to a Linux server: command line and SFTP.
# Connect by Command
Command is the basic operation of the Linux system. AWS supports three ways to connect by Command:
|A standalone SSH client||Download putty and other SSH clients to local computer to connect to Linux.|
|Hosting SSH client based on my browser (Alpha)||Connect from AWS console website, the prerequisite is to install EC2 Instance Connect on your instance.|
|A Java SSH client directly connected from my browser（Java required）||Directly connect from AWS console website, the prerequisite is to install Java plugin.|
Taking Hosting SSH client based on my browser as an example, steps for how to connect to a Linux server are as follows:
Refer to Set up EC2 Instance Connect to install EC2 Instance Connect module（For Websoft9 image, the module is installed by default, just skip this step.）
Login to AWS EC2 console, open 【Instance】> 【Connect】and choose the second way to connect.
Click 【Connect】, a window opens and you are connected to the instance.
After you're connected to the server through command line, the following two most common examples of operations are required.
# Sample 1: Get database password
For security reasons, each time a user deploys, a unique random database password is generated and stored in the service. Just require the following command to view:
sudo cat /credentials/password.txt //result MySQL username:root MySQL Password:@qDg1Vq1!V
# Sample2: Enable the root username
For security and regulatory requirements, AWS does not open the Linux root account by default, and only provides users with a common account. If you wish to use the root account, enable it by following the steps below:
sudo su sudo sed -i 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config sudo systemctl restart sshd sudo passwd root
# Connect by SFTP
SFTP is an FTP mode that uses the SSH protocol, also known as security-enhanced FTP. The SFTP tool is a favorite operation mode for Linux users. The following is an example of WinSCP SFTP tool to detail the use of SFTP.
# Configure WinSCP
Download WinSCP and install it, then start it and create a new connection.
Two verifications of cloud server: password verification and key-key pair verification
Password authentication（the most common way）
Key-key pair authentication
You may want to save your session details to a site so you do not need to type them in every time you want to connect. Press 【Yes】 button and type site name.
You can see this interface if the connection is valid.
# Manage files
For WinSCP, you can easily upload and download files by dragging and dropping, and can perform various settings and operations on files (folders).
In general, the files on the website are placed in the /data/wwwroot directory.
You can perform multiple operations on the VM by right-clicking on a file or folder on the server.
The relevant interface for modifying file permissions is as follows:
# Run command
WinSCP has a built-in command run function. Although the command function is limited to running non-interactive naming (that is, no feedback and process input are required during command execution), it is simple and practical for beginners.
WinSCP logs in to the server, then click on the command window icon from the menu (shortcut Ctrl+T is also available)
Execute the command (one command at a time) in the pop-up command run window. Eg: To query the memory usage, run the command
# Integrate Putty
Under certain specificities, you may need to use Putty to run commands. Since Putty is a command operation interface, you need to enter the root password every time you use it. If the password is complicated, it will make people feel troublesome. In fact, WinSCP can be integrated with Putty. After integration, you can open Putty through WinSCP and log in to the server automatically.
Open the 【Preferences】>【Integration】>【Application】 and input the local address of your Putty, click OK.
After completing the integration, you only need to open the Putty through Winscp's window shortcut.
Opening a Putty operation via Winscp is no different than opening a putty directly.