Restart Ssh



July 25, 2019 by Sana Ajani, @sana_ajani

Remote - SSH: Easy, smooth, and (like) local

In case you missed it, Visual Studio Code recently released the Remote Development extensions. The Remote extensions allow you to develop against a container, a remote machine or virtual machine (VM), or the Windows Subsystem for Linux (WSL), while using VS Code with its full feature set as your development environment.

Restart Linux server using putty ssh client. You must have the following information in order to reboot the Linux box: Linux server IP address or FQDN: For example, 192.168.2.18 or 202.54.1.1 or server1.cyberciti.biz. Ssh-keygen -t rsa -b 2048. This will generate the SSH key. Press Enter at the following prompt to save the key in the default location. You will then be prompted to enter a secure passphrase but you can leave that blank. Add SSH keys to your VM. In the previous step, we generated an SSH key pair. Secure Shell (SSH) is a cryptographic protocol that allows a client to interact with a remote server in a secure environment. High-level encryption protects the exchange of sensitive information and allows flie trans or issue commands on remote machines securely. Learn how to enable SSH on CentOS 7 by following the instructions in this short. To restart ssh you either have a ascript in /etc/init.d or you have svcs and svcadm command You can also add your environment variables to /.login file. Configure an interpreter using SSH Prerequisites. A ssh server should run on a remote host, since PyCharm runs remote interpreter via ssh-session. If you want to copy your sources to a remote computer, create a deployment configuration, as described in the section Create a remote server configuration.

Limitless: You are not bound to your local machine

More and more developers work on large and complex projects that require them to work against specialized developer VMs or servers that offer more storage or compute power than a normal laptop.

However, this kind of development comes with its fair share of challenges:

  • If you're using remote access software (like VNC), you'll likely experience a lag when editing because your UI is no longer local.
  • If you're using the Remote Desktop Protocol (RDP), it can be hard to manage multiple connections.
  • Mounting the remote file system and executing bulk operations can be slow.
  • It's annoying to keep your remote and local environments in sync and you often hit problems where things work in one place, but not the other.
  • Remotely editing files using SSH and Vim means you're no longer in the comfort of your go-to coding editor.

Wouldn't it be great to break out of the physical limitation of your local machine without giving up your tools. Now comes the magic of the Remote - SSH extension.

Remote Development with Linux

As long as your Linux VM supports SSH, it can be hosted anywhere; on your local host, on premise, in Azure, or in any other cloud. You can also be on any client - Windows, macOS, or Linux.

Note: macOS and Windows SSH hosts are not yet supported.

How to restart ssh on linux

In this blog post, we'll use a Windows client and target a Linux VM on Azure.

Get started

To get started, you need to have done the following:

  1. Install an OpenSSH compatible SSH client (PuTTY is not supported).
  2. Install Visual Studio Code.
  3. Have an Azure subscription (If you don't have an Azure subscription, create a free account before you begin).

Create a VM

If you don't have an existing Linux virtual machine, you can create a new VM through the Azure portal. In the Azure portal, search for 'Virtual Machines', and choose Add. From there, you can select your Azure subscription and create a new resource group, if you don't already have one.

Now you can specify details of your VM, such as the name, the size of, and the base image. We will choose Ubuntu Server 18.04 LTS for this example, but you can choose recent versions of other Linux distros and look at our supported SSH servers.

Set up SSH

There are several authentication methods into a VM, including an SSH public/private key pair or a username and password. We strongly recommend using key-based authentication so you do not need to enter your password each time you connect. If you're on Windows and have already created keys using PuttyGen, you can reuse them.

If you don't have an SSH key pair, open a bash shell or the command line and type in:

This will generate the SSH key. Press Enter at the following prompt to save the key in the default location.

You will then be prompted to enter a secure passphrase but you can leave that blank.

Add SSH keys to your VM

In the previous step, we generated an SSH key pair. We'll take the public key and paste it into our VM setup, by copying the contents of the id_rsa.pub. You also want to allow your VM to accept inbound SSH traffic.

A cool feature of using Azure VMs is the ability to enable auto-shutdown (because let's face it, we all forget to turn off our VMs…). If you go to the Management tab, you can set the time you want to shut down the VM daily.

Select Review and Create and Azure will deploy your VM for you!

Restart Ssh Service Linux

Connect using Remote - SSH

Now that we've covered how to create an SSH host, let's connect to it!

The VS Code Remote - SSH extension allows you to connect to a remote machine or VM using SSH, all from inside VS Code. If you don't already have the Remote - SSH extension installed, you can search for 'remote ssh' in the Extensions view (Ctrl + Shift + X).

You'll have noticed an indicator on the bottom-left corner of the Status bar. This indicator tells you in which context VS Code is running (local or remote). Click on the indicator to bring up a list of Remote extension commands.

Choose the Remote-SSH: Connect to Host command and connect to the host by entering connection information for your VM in the following format: user@hostname.

The user is the username you set when adding the SSH public key to your VM. For the hostname, go back to the Azure portal and in the Overview pane of the VM we created, copy the Public IP address.

Set the user and hostname in the connection information text box.

VS Code will now open a new window (instance). You'll then see a notification that the 'VS Code Server' is initializing on the SSH Host. Once the VS Code Server is installed on the remote host, it can run extensions and talk to your local instance of VS Code.

You'll know you're connected to your VM by looking at the indicator in the Status bar. Now it shows the hostname of our VM!

The Remote - SSH extension also contributes a new icon on your Activity bar, and clicking on it will open the SSH explorer. Here you can configure your SSH connections. For instance, you can save the hosts you connect to the most and access them from here instead of entering the user and hostname.

Once you're connected to your SSH host, you can interact with files and open folders on the remote machine. If you open the integrated terminal, you'll see you're working inside a bash shell while you're on Windows. Hold up, we're already connected to our VM? That was way too easy. That's the point. These extensions make remote development feel easy, smooth, and… well, not remote. 😃

You can use the bash shell to browse the file system on the VM. Create a new folder 'demo' with mkdir demo, and you can browse and open folders on the remote home directory with File > Open Folder.

You can also install extensions specifically on the remote SSH host. Extensions that affect the UI, like themes and snippets, are installed locally and the remaining extensions will need to be installed on the remote SSH host. You'll notice there's two sections when you open the Extensions view, one for extensions on your local machine and one for extensions on your remote host. Even if you SSH into your remote machine from different clients, your remote extensions and setup will remain the same. When you go to install an extension, VS Code will automatically install it in the correct context.

Hello World

Let's deploy a basic 'Hello World' Python app to our VM. We'll be using a popular Python web framework called Flask. In your bash shell, run the following command.

In the 'Demo' folder you made earlier, create a new file (Ctrl + N) named app.py with a basic Hello world Flask application.

Once VS Code identifies the file language as Python, you'll see a notification recommending the Microsoft Python extension if it is not already installed on the remote machine.

Select Install, reload VS Code, and you'll start seeing VS Code's IntelliSense and colorizations on our remote machine.

To run the app, press F5, and select the Flask debug configuration. In the Python Debug Console, you'll see that the app is running on localhost at port 5000. However, localhost currently refers to the remote server, not your local machine. To be able to browse to the web app on your local machine, we're going to leverage another feature called Port Forwarding.

To be able to access a port on the remote machine that may not be publicly exposed, we need to establish a connection or a tunnel between a port on our local machine and the server. With the app still running, open the SSH Explorer and find the Forwarded Ports view. Click on the Forward a port link and indicate that we want to forward port 5000:

Name the connection 'browser':

The server will now forward traffic on port 5000 to our local machine. When you browse to http://localhost:5000, you see the running web app.

Now, the real question is…can we debug from VS Code on our remote machine? YES! With the app still running, put a breakpoint on the line that returns the string 'Hello Remote World' and select the restart button in the debugging control. Refresh the page in your browser and you'll hit the breakpoint! You're getting the same VS Code experience, with editing, debugging, and all your settings and extensions. 😊

To switch back to your local machine for local development, you close the remote connection with File > Close Remote Connection.

Using the Remote - SSH extension, you can work against a VM with all of VS Code's productivity features and extensions on your remote machine. You get the full-fledged development experience you know and love in VS Code, no matter where your code is hosted.

If you want to learn more about VS Code Remote, you can read our blog post announcing remote development. You can also try out the other remote extensions, Remote - Containers and Remote -WSL, and read our full remote development documentation.

Happy Remote Coding,

Sana Ajani, VS Code Program Manager @sana_ajani

Introduction

Secure Shell (SSH) is a UNIX-based command interface and protocol for securely getting access to a remote computer. SSH is actually a suite of three utilities - slogin, ssh, and scp - that are secure versions of the earlier UNIX utilities, rlogin, rsh, and rcp. SSH commands are encrypted and secure in several ways. Both ends of the client/server connection are authenticated using a digital certificate, and passwords are protected by being encrypted.

In short, SSH allows you to connect to your server securely to perform Linux command-line operations. And although you will be running Linux commands, SSH can still be performed from a Windows, Mac, or Linux computer.

Requirements

To get started, please visit your Server Guide in the Account Center, and make sure you have the following information ready:

  • IP address for your server

    NOTE:

    If DNS is set up for a domain you are hosting, you may use the domain instead of the IP address.

  • Your SSH username and password

Set root password

You will need to set your root password in the Account Center the first time you connect to your server.

  1. Log into your Account Center.
  2. Click on your primary domain.
  3. Click on SSH Access.
  4. Click on the option to set your root password.
  5. Type your new password twice, then save your changes.

Instructions

Enabling SSH access

For security reasons, your Grid comes with SSH access disabled by default. Here are instructions for enabling SSH access:

  1. Log into your Account Center and click on your primary domain.
  2. Click on Server Administrator.
  3. Set the SSH option to Enabled and click Save.
Restart ssh server

NOTE:
This option enables SSH for the Server Administrator user only. This is the only Grid SSH user with wide-reaching permissions.

Instructions

Enable or Disable SSH access

  1. Log into your Media Temple Account.
  2. Click on the ADMIN button associated with your Managed Wordpress server.
  3. Click on the Settings tab.
  4. Click Show More.
  5. Locate SSH and select the slider.

For Premium WordPress / Managed WordPress Personal, Pro, and Elite:

1. Log into your Account Center and enter the Managed WordPress Control Panel.


2. Click on Manage Site for the site you would like to enable access for.
3. From the My Site

Restart Ssh Ubuntu

menu, find the SSH + SFTP panel and make sure that SSH Access is on.

Instructions

Enable SSH access

On the DV and DV Dedicate-Virtual servers, you have several possible SSH users. Choose the appropriate one for your needs.

SSH for root user

For high-level configuration tasks and server administration, you can enable the root user for your server. This user can modify absolutely everything, so make sure you use it wisely. See Enable root access for instructions.

SSH using sudo

For high-level tasks coupled with increased security, you can set up a sudo user instead. This user normally functions as a lower-level user, but can perform the same tasks as root when necessary. See How do I disable SSH access for the root user? for more information.

For all examples that pertain to the root user, a sudo user can do the exact same thing by adding sudo in front of the rest of the command. You will be prompted for the root password, and then the command will execute.

Example root command:

Same command for a sudo user:

SSH for FTP user

For domain-specific tasks, you can enable SSH access for the FTP user associated with that domain. This is the best option if you plan to copy or create web-accessible files.

Plesk

  1. Log into your domain's Plesk Control Panel.
  2. Note the name of your System user, then click FTP Access.
  3. Click on your System user.
  4. Click on the drop-down menu and select /bin/bash.
  5. Then click OK or Apply to save your changes.

cPanel

  1. When you create an account in cPanel, you will be prompted to create a username/password. These credentials can be used to access your domain via SSH.
  2. For existing accounts the password can be updated by logging into cPanel and clicking on Password & Security.
  3. Alternatively, you can login into WHM and click on Account Functions >> Password Modification.

Choose a SSH client

You will first need to choose an SSH client.

  • Mac OS X includes the SSH client Terminal by default.
  • Windows-based Operating Systems do not come with an SSH client by default. We recommend PuTTY. For information, please see: Using SSH in PuTTY (Windows).
  • Linux distributions include support for SSH by default as well. Simply start up a terminal.

You should use the following information to log into the server via SSH (replace 00000 with your site number):

  • Server: s00000.gridserver.com
  • Username: Your Server Administrator Username (example.com)
  • Password: This is the same as your Server Administrator FTP password. Read this article if you need to reset this password.

You should use the following information to log into the server via SSH (replace example.com with a domain name that resolves to your server):

  • Server: example.com or your IP address
  • Username: This depends on which user you chose to enable. The root username is just root. Your domain FTP user or a different sudo user will have a custom name depending on what you typed when you created the user.
  • Password: This depends on which user you chose to enable. The root and sudo articles above show how to set a password for those users. The domain FTP user will have the same password that you use for FTP.

Connecting to the server

If you are new to command-line interfaces, you may want to familiarize yourself with some of the commands first.

It is standard to hit 'Enter' after each command, to execute it after you finish typing.

Restart Ssh Service Ubuntu

  1. Open your SSH client.
  2. To initiate a connection, type:Replace 'username' with the username and 'hostname' with the hostname found in the SETTINGS section of your WordPress control panel under SSH & SFTP.
  3. Type:OR

    NOTE:

    If you are trying to connect as a sub-FTP user on the Grid, you will want to use the following command context:

    In this case, the username is the full email address. But, you will need to replace the @ symbol in the email address with a % to make sure the command works.

    Username: subftpuser%example.com
    Password: This is the same as your email password.
  4. Make sure you use your own domain name or IP address. If you want a user other than root, type the other username before the @ symbol.

    Type:

    OR (IP address version)OR (domain FTP user version)
  5. Be sure to replace xxx.xxx.xxx.xxx with your server's IP address. Type:
  6. If this is your first time connecting to the server from this computer, you will see the following output. Accept the connection by typing 'yes.'
  7. You will now be prompted to enter your password. Please note that you will NOT see your cursor moving, or any characters typed (such as ******), when typing your password. This is a standard Terminal security feature. Hit enter.
  8. You can also copy and paste, using Command+V to paste.
  9. That's it, now you're connected to your Managed WordPress service via SSH.
  10. You are now logged into your Grid via SSH. You should see output like this:

    You can begin typing commands at the prompt.

  11. You are now logged into your server via SSH. You should see output like this:

    You can begin typing commands at the prompt.

  12. The output will look something like this:

    You can begin typing commands at the prompt.

Restart Ssh Agent Mac

Resources