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!
Cygwin not only provides most of the Linux programs and shells, it also comes with a builtin X server called Cygwin/X. This is great if you want to run Cygwin GUI applications locally or over SSH from a remote computer.
- Install Cygwin, if you do not already have it.
- Use the Cygwin setup program and install the
xinit packages. The first one is the X server and the second installs a lot of scripts and programs that enable you to start the server and use it.
- Install the
xeyes package. This is a small X application that we will use for testing X.
Use Cygwin/X for local apps
- Kill the
XWin and other X server processes if they are running and close all your Cygwin windows. Open a new Cygwin window.
- Set the
DISPLAY environment variable:
$ export DISPLAY=:0.0
- startx: If you run
startx, you get X server opening a X window with XTerm running inside it. From here on, you can open X apps by running them from that XTerm. You can try by running
xeyes inside that XTerm. Once you kill this X window, your X server is closed.
startxwin: If you run
startxwin, you get X server running, but no windows are displayed. You can now open another Cygwin window and can invoke individual X apps there and they will be displayed in individual windows. You can try by running
xeyes from the Cygwin shell. This is called the multiwindow mode.
Use Cygwin/X for remote apps
- Follow all the steps shown above for local X apps. Make sure you have killed the earlier X server processes, set the
DISPLAY environment variable locally and run
startxwin. Make sure local X apps can display a window to the Cygwin/X server.
- SSH to the remote computer running Linux using ssh on Cygwin or PuTTY. Make sure you have X11 Forwarding enabled for this SSH session. This is usually done by specifying
-X (untrusted forwarding) or
-Y (trusted forwarding) or setting the corresponding X11 Forwarding option in your SSH config file.
- Check the
DISPLAY on the remote computer. It should be set to some value like shown below:
$ echo $DISPLAY
DISPLAY is empty, then either you did not set
DISPLAY locally, did not cleanly restarted a X server locally or there was a problem with SSH X11 Forwarding. Please diagnose.
- Run the
xeyes program from the remote computer. It should display in a window on your local machine. Your Cygwin/X server is working! You can now run GUI/X apps from the remote computer and display them locally. Beware that they will be slow to display and refresh.
Tried with: Cygwin 2.10.0 and Windows 10
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
A SSH session gets hung or frozen sometimes. To exit or kill the SSH session and get back to the local shell, press this key sequence:
That is you press 3 keys in sequence: Enter, then tilde and then period.
Tried with: OpenSSH 5.9p1 and Ubuntu 12.04 LTS
The ssh command can be passed the name of the host computer and your login on it. After this it asks for the password. However, you may sometimes want to issue the password along with the ssh command.
One possible solution for this is to use the sshpass tool. The tool can be installed easily from the Ubuntu repositories:
$ sudo apt-get install sshpass
To issue your password along with your ssh command, use this:
$ sshpass -p "mypassword" ssh mylogin@myhost
Tried with: sshpass 1.05 and Ubuntu 12.04 LTS