It is convenient to connect to a remote computer using SSH and work at the shell. But viewing images files and other such common files can be a problem. Using a X server might not always be possible. A simple solution that works for me is to use the SimpleHTTPServer module that ships in Python.
- Change to the directory which holds the files you want to view from a remote computer.
- Run the SimpleHTTPServer there and provide a port number for the server:
$ python -m SimpleHTTPServer 8901
- On the local computer, open a browser and connect to the server using the address:
- You can now view image files and other common file types right in the browser.
Tried with: Ubuntu 18.04
Visual Studio Code is a great editor for local files. Remote VSCode is an extension that enables editing files on remote systems in your local VSCode. Note that you will need to specify individual files on the remote computer and they will appear in your local VSCode. You cannot open a remote folder and expect all of the code there to be indexed for code browsing with this method.
- Install rmate on the remote computer. rmate has been ported from its original Ruby implementation to Python, Bash and other languages. I like to use rmate-python. Installing it is easy:
$ sudo pip3 install rmate
//-------- Remote VSCode configuration --------
// Port number to use for connection.
// Launch the server on start up.
// Address to listen on.
// If set to true, error for remote.port already in use won't be shown anymore.
$ ssh -R 52698:127.0.0.1:52698 yourlogin@remotecomputer
- Once you are SSHed into the remote computer, run this command there:
$ rmate -p 52698 file/you/want/to/edit
The file will appear in your local VSCode for editing. The remote file will be updated with any changes you make locally after you save the file.
Tried with: Visual Studio Code 1.22.2 and Remote VSCode 1.1.0
I installed the latest stable release of ConEmu. I opened a Cygwin shell and used SSH to connect to a remote computer. I ran Byobu on the remote computer. I noticed that its status bar would shift upward, overwriting the entire screen after some time.
This problem is documented here. The solution suggested by the ConEmu creator is to use the ConEmu/msys terminal connector plugin. Using this connector is however a bit complicated. But, according to this post, it has been rolled into ConEmu starting with the 170705 release. I checked and found that the stable release I had installed was 161206. The stable release was years behind!
Seeing no recent stable version available, I opted to download a preview release from here. This release was dated later than 170705. byobu worked fine through SSH from Cygwin after that!
I tried to SSH to a server using a private key file and got this error:
$ ssh -i myprivate.key 10.0.0.100
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Permissions 0664 for '/home/joe/myprivate.key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: /home/joe/myprivate.key
This key file strangely had access permissions by all to read, write and execute! SSH was complaining that such a file is too open and could be compromised. I reduced the access permissions to just read by me:
$ chmod 0400 myprivate.key
SSH worked after this change 🙂
Tried with: SSH 6.6 and Ubuntu 14.04
There are times when you want to check if you are in a SSH session from your shell. For example, I like to change the shell prompt based on whether it is in a local machine or in a SSH session on another machine.
An easy way to do this is to check if any environment variable related to SSH has been set. For example, I check if the
SSH_CLIENT variable is set in my shell. In Fish, this can be done by checking the result of
set --query SSH_CLIENT for example.
Normally when you SSH into a computer, you need to provide a username and it will prompt you for your password, like this:
$ ssh joe@server_machine
By generating a public-private key pair on the local machine and sharing the public key with a remote machine, you can SSH to the remote machine without providing a login or being prompted for a password.
After this setup is done, you will operate like this:
$ ssh server_machine
$ That is it! You are logged in without login or password!
To set this up:
- Generate a public-private key pair on your local computer. If you already have one (probably you generated it for Github) and want to use that, then skip this step.
$ ssh-keygen -t rsa -b 4096 -C "email@example.com"
This generates a public key in
~/.ssh/id_rsa.pub and its corresponding private key in
- We need to add the public key from local machine to the
~/.ssh/authorized_keys file on the remote computer you are logging to. You can do this manually. However, the
ssh-copy-id script does this for you. Just pass the remote computer name as input:
$ ssh-copy-id remote_machine
If there is no
~/.ssh/authorized_keys file on the remote machine, this script will create it for you. If the file exists, your public key from local machine will be appended to the existing file.
Reference: Arabesque: Linux Crypto – SSH Keys
Tried with: Ubuntu 14.04
DigiSSHD is one of the many SSH server apps for Android devices. This app requires a rooted device. If your device is not rooted, it will just fail to execute.
Tried with: DigiSSHD 0.2.2, Moto G2 (XT1068) and Ubuntu 14.04
The SSH Server app from Ice Cold Apps enables you to SSH into any Android device. I use this to SSH from my Ubuntu computers to my Android devices, both connected to my home wireless network.
- If you have not rooted your phone, you will not be able to access privileged directories and files. You will also have to pick a port number that is bigger than 1024.
First, create a Server and create a User in the app. Remember to specify a port number that is bigger than 1024. Start the server to run the SSH server.
SSH to the Android device using its IP address, the username you created and the port you specified. You will be asked to accept its key and will be prompted to enter the password you specified earlier:
$ ssh firstname.lastname@example.org -p 1700
- Assign a static IP address to your Android device for easier access, so that you do not have to look up what IP address has been assigned to it every time.
Tried with: SSH Server 3.1, Moto G2 (XT1068) and Ubuntu 14.04
I SSH to another Linux computer and get this error:
$ ssh email@example.com
ssh: connect to host 172.20.128.100 port 22: Connection refused
Typically, there is no complicated reason of permissions why this failed. Since the OpenSSH client is almost always installed by default on Linux computers, people assume that the OpenSSH server is also installed. It is not and it gives this error!
Install the OpenSSH server on the host and you should be able to SSH to it:
$ sudo apt install openssh-server
Tried with: Ubuntu 14.04