I am running Ubuntu 14.04.1 LTS 64-bit on both of my laptops and they are both connected to the same home Wi-Fi at the moment.

I want to connect to the other computer via one of the computers, say through SSH, how can I do so? What credentials should I know about both computers and which command should I use?

My intention is not simple file sharing and I want some other solution than Teamviewer etc. although X-Windows forwarding would be nice. I appreciate your assistance in this matter.

Edit: When I try SSHing I got the following on the prompt:

VesnogXPS:~$ ssh ongun@
ssh: connect to host port 22: Connection refused

Edit2: The above problem is resolved but now it cannot read the .bashrc on the connected computer the permissions for the file is as follows:

-rw-r--r-- 1 ongun ongun 3567 Jan  4 01:06 .bashrc

The error I get is as follows and it is present in only when connecting from A to B not while connecting from B to A:

ongun@'s password: 
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-45-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

Last login: Thu Feb 19 18:52:54 2015 from
-bash: /home/ongun/.bashrc: Permission denied

The contents of the ~/.profile on the problematic laptop is:

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    PATH=/usr/local/texlive/2013/bin/i386-linux:$PATH; export PATH 
    MANPATH=/usr/local/texlive/2013/texmf-dist/doc/man:$MANPATH; export MANPATH         INFOPATH=/usr/local/texlive/2013/texmf-dist/doc/info:$INFOPATH; export INFOPATH

Figured the problem out it was not sourcing the .bashrc I did change the line after the second if as follows: . "$HOME/.bashrc"

Now everything works perfectly, but I have one more question, why did it use to work for the terminal emulator on the local machine but not SSH itself? I am asking this since both are interactive login shells.

  • @user68186 The intention is not file sharing only.
    – Vesnog
    Feb 19 '15 at 14:18
  • @user68186 Thanks for now I would like to go with SSH but I wanted for command-line interface but I also wanted to know the other options possible.
    – Vesnog
    Feb 19 '15 at 14:36

At first you need to know the IP addresses (try ifconfig or ip addr show or any other method) of the laptops lets say Laptop A's IP is "" and Laptop B's IP is "". To do ssh from A to B and vice versa you need to install the ssh server on both laptops by following command:

sudo apt-get install openssh-server

As client is automatically installed by default you now should be able to ssh either directions by:

ssh username@ ##From B to A
ssh username@ ##From A to B

Here "username" is any user of "" as whom you are logging in.

If you want ssh X11 forwarding try this:

ssh -Y username@
ssh -Y username@

Read manpage of ssh to get more idea.

EDIT: As "Rmano" suggested in the comment, you can check for "DHCP preallocation". Have a look at this and this.

Answer to the EDIT: I think you have not installed openssh-server on leading to the error connection refused. You can check which tcp ports of are in listening state for connections by doing

netstat -tlpn

from and then look for port 22 by netstat -tlpn | grep 22. You can also check this from

nmap -PN

Answer to the 2nd EDIT: The problem is that in your ~/.profile instead of sourcing the ~/.bashrc file by . $HOME/.bashrc it is doing "$HOME/.bashrc". The code snippet should be:

if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
  • 1
    @Vesnog: It seems that your subnet is, you can use nmap -sP to find out all other live hosts in the subnet.
    – heemayl
    Feb 19 '15 at 14:12
  • 1
    @Vesnog: You can but i strongly thinking there is some wrong line in any of these files. Does the shell prompt comes up or just stuck in the permission issue forever?
    – heemayl
    Feb 19 '15 at 17:07
  • 1
    @Vesnog: I see, try source ~/.profile
    – heemayl
    Feb 19 '15 at 17:12
  • 1
    @Vesnog: I was waiting for you in the chat, i just checked in here some time ago and found the ~/.profile entry. Seems we have found it at the same time. Check my 2nd edit. Weird that i did not get any notification of your last comment, otherwise it would be faster ;)
    – heemayl
    Feb 19 '15 at 17:34
  • 1
    Yes, there are differences. While doing ssh you are getting a login-interactive shell whereas when you are opening the terminal from GUI you are opening a non-login-interactive shell. Check this unix.stackexchange.com/questions/38175/…
    – heemayl
    Feb 19 '15 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.