How to Install and Use SSH (Secure Shell) in Ubuntu
- select the contributor at the end of the page -
SSH or secure shell, is a protocol that allows you to securely access one computer from another. Not only can you transfer files, but if you are concerned about public wi-fi security, SSH can help. Using the command line or a graphical interface, you can bypass potentially prying eyes and create a secure virtual private network (VPN) that tunnels your Internet traffic through your home computer's connection.
To use SSH, you'll need to install the SSH client on the computer you connect from, and an SSH server on the computer you connect to. Under Linux, the most popular software provider is the OpenSSH project.
How to Install OpenSSH
OpenSSH is of course, an open source product and contains both the client and server components.
The client software is part of the default Ubuntu installation. If you want to be able to accept SSH connections as well as request them, you'll need the server software as well. Install it with this command:
sudo apt-get install openssh-server
How to Use SSH to Login to a Remote Computer
In order to access a remote computer, you'll need to have an account on that machine. You may want to set up a guest account. Navigate to System > Administration > Users and Groups. Create a user (or group of users) and assign the permissions as needed.
When OpenSSH is installed and your user created, login to the remote computer with this command:
Username is the name of the user you created and hostname is the name of the computer (or host) or its IP address. So if you had a computer at home with an account called janedoe, from the command line you would type:
ssh [email protected] or ssh janedoe@myhompc
Copying Files using SSH
Now that you've made the connection to your remote computer, you'll probably want to transfer or copy some files. The secure copy command (scp) allows you to securely copy files to and from the remote box. The syntax is as follows:
scp filename.extension remoteuser@remotebox:/directory
Copying Directories using SSH
To copy an entire directory (and all of its contents) from the local machine to the remote server, use the recursive
scp -r /local/directory remoteuser@remotebox:/remote/directory
/local/directory is the path to the local directory you want copied, and /remote/directory is the remote directory where you want the directory to be copied.
To reverse this and copy from the remote box to local, just switch things up accordingly:
scp -r remoteuser@remotebox:/remote/directory /local/directory
What about Windows?
For more detailed information behind these communications protocols, visit the Ubuntu Wiki for your version. Also remember to keep permissions in mind if you choose to provide remote access to other users. Restrict access to only those files or directories that are absolutely required. I hope you've enjoyed our look into remote access under Ubuntu.