ssh,raspberry-pi,raspbian , Keeping a connection with remote computers

Keeping a connection with remote computers


Tag: ssh,raspberry-pi,raspbian

I have a series of RPi's running Raspian which need to deployed in various location around the world.

They will have internet access, but will all be behind a router. Is there an off-the-shelf solution to keep the possibility to create a SSH connection to them? I am thinking about solving problems, upgrading etc.

I am thinking of a 'server' solution where a 'client' on the RPi keep an active connection so a SSH connection can be established when required. Any suggestions will be much appreciated!


I have experimented with several services including LogMeIn Hamachi and Weaved among others. I would highly recommend using Weaved because it allows you to meet your goal (SSH to pi behind a router), and the setup is painless. You may even find some other uses that are quite handy.

See the installation details at

Steps to be up and running:

  1. Go to and sign up.
  2. Install weaved on your pi, and follow the prompts for SSH (Instructions at
  3. Go to "My Devices" at and get the new internet accessible proxy address for your pi.
  4. Enjoy!


BASH Script to SSH to another server and run commands as user

I read a lot though the forums and Google however I wasn't able to locate a workaround for this particular one. Basically my script is running on my local machine, then is SSH-ing onto a server with a different username (it works up until here), and on that machine I...

Why doesn't “Set-Item” work on Windows 7 PowerShell?

I am trying to install Windows 10 IoT on my Raspberry Pi 2. The PowerShell documentation tells me to put in this: Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc> However, when I put it into my Windows 7 PowerShell, this comes out: At line:1 char:54 + Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc> + ~ The...

Can you create a project on GitLab using ssh?

I have an account with I am trying to automate some of the steps of setting up a new dev server. Is it possible to connect to my account at via ssh and then create a new project? If so, how? If no, why not? Currently I get...

Python Flask persistent object between requests

I am creating a web interface for OMXPlayer on the Raspberry Pi. I'm trying to create a more REST like API for controlling the video while its playing. The issue I'm having is how to control the video while it is playing. Currently I can create a Player object which...

Configure Git to use a .pem key from a specific location

Whenever I try to do a 'git pull origin master' I get (It is NOT Github): Permission denied (publickey). I am able to SSH into my AWS EC2 Linux sever, which has the bare repository, which I'm trying to pull from when I get the aforementioned permission error. I have...

Raspberry Pi MicroSD Boot not working, MicroSD card unreadable on PC

I downloaded the necessary files for Raspberry Pi onto a MicroSD card, although the MicroSD card is no longer readable. When I put the card into the computer through a MicroSD to USB adapter nothing shows up in Windows Explorer. The card isn't present in Windows Disk Management either. How...

how to ssh run a tail and then send data to a mysql database

This code SSH's and then runs a tail command on a remote hots. I would now like to pass that tailed data into a mysql database using a local script called How do I pass data generated in a ssh session into the local shell script The local...

how to immediately login through ssh?

Here is my problem. I need to run a command ./ -u 1540 This will fetch version 1540 of on SVN When I do, the script access SVN and ask for a password. I'm using ssh. It will first ask me a password since it guesses my SVN login...

Raspbian log files

Where can I find all boot, driver or kernel related logs on a Raspbian? Could you please reply with a list as follows: Driver logs - /something/somethingelse.log Thanks!...

How can I figure out which process is opening the certain tcp port?

I usually use fuser command to check pid opening the certain tcp port like the following fuser 22/tcp //To get pid opening the 22 tcp port I've got a reference board which running a embedded linux. It have been already opening 22 tcp port for ssh connection. But fuser doesn't...

Jumbled out put of RFID Tags

I am working on a project, in which I have to interface multiple RFID Readers (I'm Using EM 18, With Serial out) with Raspberry Pi. I'm using an USB to TTL Converter to connect EM 18 to Raspberry Pi. I've connected two RFID Readers using USB to TTL Adapter. This...

GPS App compile errors

I am working on a GPS application on the Raspberry pi. I have just installed GPSD by running sudo apt-get install gpsd gpsd-clients. I do get data from my GPS module when I run sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock. My issue resides when I try to make my own GPS...

C# Simple SSH Connection And Send Command

this is the code i'm using SshClient cSSH = new SshClient("", 22, "root", "pacaritambo"); cSSH.Connect(); SshCommand x = cSSH.RunCommand("exec \"/var/lib/asterisk/bin/retrieve_conf\""); cSSH.Disconnect(); cSSH.Dispose(); but i want to send command from a textbox so I've tried this SshCommand x = cSSH.RunCommand(textbox3.Text); but didn't work basically i want textbox3.Text as a ssh command....

Capistrano deploy with bitbucket - Permission denied (publickey)

After adding public key to bitbucket acct, ssh -T [email protected] returns (in windows): The authenticity of host ' (' can't be established. RSA key fingerprint is 65:8c:1b:f2:6f:91:6b:5c:3b:ec:4a:46:46:74:7z:40. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '' (RSA) to the list of known hosts. logged in...

SSH remote command

I have a strange SSH problem. If I run this ssh [email protected] 'md5sum file.txt' I get back the result as expected, but if I run this ssh [email protected] 'cat file.txt' then it just sits there....

using sed to replace a line with back slashes in a shell script

I am trying to replace the bottom one of these 2 lines with sed in a file. <rule>out_prefix=orderid ^1\\d\+ updatemtnotif/</rule>\n\ <rule>out_prefix=orderid ^2\\d\+ updatemtnotif/</rule>\n\ And the following command seems to do that when executed as a command at the bash prompt sed -i '[email protected]_prefix=orderid ^2\\\\d\\+ updatemtnotif/@out_prefix=orderid ^2\\\\d\\+ updatemtnotif_fr/@g' /opt/temp/rules.txt however, when...

How to open a new terminal from my working terminal with same directory in Linux?

Is there any command to open a new terminal from my working terminal with same directory while working with ssh in Linux? e.g., I am working in the following terminal. My pwd is /home/work/Kayan01/test_run I want to open a new terminal directly from my working terminal, so that the pwd...

Openshift port-forwarding [on hold]

After many hours and many attempts, remains now your help. Im trying to do port-forwarding to access my DB in Openshift on Neatbeans. I've already done lots of tutorials, upgrade and downgrade versions of net-ssh, uninstall rhc and so on. I have read a lot git solutions (ssh_options[]...) and doesn't...

C++ chrono library on Raspberry Pi

On a Raspberry Pi 2, I need to call a php file on a regular basis, typically every 100ms. I found this c++ code which looks like it does what I need and a test version of it compiles and runs fine using CodeBlock on Windows. I've updated the wheezy...

Creating a Virtual Machine on Bluemix, is giving an error while importing ssh key [closed]

I am following the steps to create Virtual Machine on Bluemix following the steps as below. I am blocked when I am trying to configure a SSH key. I am using an existing key pair which I use with my other machines. I get an error "Keypair data is...

run python script with arguments on a remote linux host

I have this python script that I'm trying to run on a remote host. However, the script requires two arguments. For example, python --port 4000 --service status Now when I run the script locally on the machine it works fine. How can I run this same script on a...

How deploy an large number iBeacons

I want deploy a large number of iBeacons with the same UUID because we can't access dynamically to the UUID of the beacons detected. What is the limit number of the maximum Beacons with the same UUID ? I found some discussions with a number of 65000 approximately, is it...

Java and SSH looking to execute multiple commands from a file, across a list of hosts in another file and write the output to a file

“my-thoughts” Provided the code below. but it’s not working 100%. 1) if I have more than one command, the program won’t run. 2) one command in the command file, the script won’t execute properly. for example with “ls” the log file will have the following "Last login: Tue Jun 9...

Java read bytes from Socket on Linux

I'm trying to send a file from my Windows machine to my Raspberry-Pi 2, and I have a client and a server. The client should be able to send a zip file over the network to my server on my linux machine. I know my client and server work on...

Raspberry PI USB to RS232 adapter Receiving Only Ctrl Chars

I'm using a USB to RS232 cable for get communication with a pure rs232 device. With pyserial lib a got this code running in loopback tx -> rx cable pins. Setting the port: def __init__ (self, baudrate,timeout,parity,stopbits,bytesize): try: #self.s = serial.Serial(port="'/dev/ttyUSB0'",baudrate=baudrate,timeout=timeout,parity=parity,stopbits=stopbits,bytesize=bytesize) #self.s = serial.Serial("/dev/ttyUSB0",9600) self.s=serial.Serial( "/dev/ttyUSB0", baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,...

Atlassian Stash - Permission Denied (publickey)

I'm actually in the process of setting Atlassian Stash for my Workplace. I've ran into this issue which I'm not able to fix. Note, this is running on a Windows 7 64bits installation. When setting the SSH Keys, I followed the Stash Guide on how to create them and set...

Capture SSH Response to variable

I am currently trying to "talk" to a router using SSH commands via C#. I am using the model. public void connectSSH(string hostName, string username, string password) { using (var client = new SshClient(hostName, username, password)) { client.Connect(); client.RunCommand(CommandList.showEnvironment()); client.Disconnect(); } } This is the code I have so...

How to install shared library and include files manually in linux?

I am trying to build and install TBB library from source so that it can be used for OpenCV to take advantages of multiple cores on my raspberry pi. I was able to build TBB from source without any problems using this steps. (Source : How do I build OpenCV...

Expect Script through Putty works but not when called by scripts executed via http

I have an expect script that connects to one of our remote servers, it runs a few commands as admin then exits. When i run the script through the Putty CLI it works properly. However when I call the script via http it fails, the script isn't presented with the...

Popen.kill() failing

Update 2: So I piped the output of stderr and it looks like when I include shell=True, i just get the help file for omx player (it lists all the command line switches and such). Is it possible that shell=True might not play nicely with omxplayer? Update: I came across...

Updating An Image on All instances of a website

So I have a Raspberry Pi controlling my Garage door. The Pi is running an apache webserver. I also have a camera connected to the raspberry pi and I want to be able to update the images from the camera. Currently I have the following code: garage.html: <html> <head> <meta...

git ssh doesn't work

I have done what the document said, and when I type ssh -T [email protected], it will show Warning: Permanently added the RSA host key for IP address '[]:443 ' to the list of known hosts. Hi fifiteen82726! You've successfully authenticated, but GitHub does not provide shell access. However, when I...

SSH Connection to MySQL

I have hit an issue and I am unsure as to where it is going wrong. I am establishing an SSH connection to my remote server and from there I am trying to access a MySQL Database. The SSH connection connects properly however, when attempting to access the MySQL db...

Use same Python variable in multiple if-statements

I am having issues with my current Python script. The purpose of the 'progress' variable is take a specific value when it goes through one of the if-loops. But, the program never goes further then the first if-statement. It looks as if every if-statement makes his own variable called 'progress'....

How do I SSH into EC2 with .pub?

When I create a new Elastic Beanstalk environment it asked me if wanted to create a new keypair. I say yes, and it created two file in my .ssh folder locally called app and Normally to ssh into an instance I use a app.pem file. i.e ssh -i app.pem...

How to verify SSH keys properly added for Git?

What's the command to verify SSH keys are properly added for git? There are 2 sets of keys under our ~/.ssh/ and we want to add both of them. What we did was to run ssh-add -l in git bash: $ ssh-add -l 2048 28:1b:b8:b2:a8:f1:9b:bb:b5:85:21:d5:d8:0b:00:b2 /c/Users/myuser/.ssh/bb_rsa (RSA) 2048 3d:31:e8:f7:f5:cd:dd:c7:0b:84:16:66:23:95:af:05 /c/Users/myuser/.ssh/id_rsa...

Error in executing a Jar file in remote machine

I am trying to executing a jar file which is present in remote machine. When I execute below command from my local machine I get error: ssh -i /root/.ssh/pem_file [email protected][host_ip]:/home/user/folder1/java -cp jar1.jar -a option1 -e [email protected] -f TextFile.txt /home/user/folder1/ is the location where jar file is present on remote machine.The...

Access GPIO (/sys/class/gpio) as non-root

The /sys/class/gpio can only be access as root by default. So I like that a new group gpio can use the files and dirs under /sys/class/gpio. To achieve that I added the following lines to /etc/rc.local (I'm on Debian): sudo chown root:gpio /sys/class/gpio/unexport /sys/class/gpio/export sudo chmod 220 /sys/class/gpio/unexport /sys/class/gpio/export So...

My While True loop is getting stuck in python

Hello I have been working on an infinite While True loop for the main file in my python code. I am working on a Raspberry Pi and my goal is that whenever one of the GPIO Pins senses an input it will print out a string. However When I push...

how to correctly write command inside commands (ssh)?

Here is the command I have which works It's just a kill with an expression which returns a number kill $(ps -ef | grep '[m]atchbox-panel --titlebar --start-applets showdesktop,windowselector' | cut -f8 -d' ') &> /dev/null Here is the ssh I normally use bash -c 'timeout 120s ssh -o StrictHostKeyChecking=no [email protected]

ssh result seems to only be 16bits in python with paramiko

im using paramiko in python 2.7 to connect to a cisco router, send a command and then parse the output of the command in a for loop. the problem seems to be that the returning result is limited to 65535 characters (16bits). I printed the output and pasted it in...

vi/fugitive: Gpush does not exit… sometimes

I just started using fugitive in my workflow... very useful! But I've seem to have run into a weird annoyance that I'm hoping someone might have a solution to: When I run :Gpush, sometimes control never returns to vi. Vi hangs on the output of git push until I Ctrl+C...

Python (3.4) run SSH commands on local terminal [closed]

I'm writing a script that I'm running through a terminal, and would like it to run BASH commands in that same terminal. All solutions that I found were geared toward connecting remotely through SSH, whereas I just need to run SSH commands on the same machine. Can someone please point...

Github: Permission denied (publickey) but I got “You've successfully authenticated” message

Step I had done: follow exactly. $ eval "$(ssh-agent -s)" Agent pid 31944 $ ssh-add Enter passphrase for /home/centos7/.ssh/id_rsa: Identity added: /home/centos7/.ssh/id_rsa (/home/centos7/.ssh/id_rsa) $ ssh-add -l 4096 ab:4d:23:23:99:ce:bb:9d:9f:9e:f9:b2:c8:1a:cd:f7 /home/centos7/.ssh/id_rsa (RSA) However, when I run $ git clone [email protected]:privateRepo/repo.git Cloning into 'repo'... The authenticity of host ' (' can't be...

paramiko: NameError: global name 'descriptor' is not defined

I'm trying to use paramiko for SSH, but got an error: >>> import paramiko >>> ssh = paramiko.SSHClient() >>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) >>> ssh.connect('54.***.***.110', key_filename='D:\Keys\MyOWN\priv.ppk') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "build\bdist.win32\egg\paramiko\", line 366, in connect File "build\bdist.win32\egg\paramiko\", line 515, in _auth File "build\bdist.win32\egg\paramiko\",...

Expect script for checking ssh connection for a list of ips

Can anyone help me in creating an expect script to just do an SSH on a list of servers and check if it was fine. I do not need to interact, do not need to fire any command on each server, I just want to do an ssh and come...

View EC2 Instance Server Files in AWS Console

Is it possible to browse server files (.php, etc.) inside the AWS Console (in the browser) and not via a SSH or FTP client? For example; view files just like in CPanel on a regular web host. I am working on a EC2 instance of a Debian OS that was...

setInterval doesn't get cleared, function keeps getting executed

I have the following function: function monitorClimate() { var sensorReadingInterval; function startClimateMonitoring(interval) { sensorReadingInterval = setInterval(function() { io.emit('sensorReading', { temperature: sensor.getTemp() + 'C', humidity: sensor.getHumidity() + '%' }); }, interval); console.log('Climate control started!'); } function stopClimateMonitoring() { clearInterval(sensorReadingInterval); console.log('Climate control stopped!'); } return { start: startClimateMonitoring, stop: stopClimateMonitoring }; }...

Python subprocess throws [Errno 2] No such file or directory, error generated only when it on a remote host

I'm running python 2.6. I'm getting the subprocess throws [Errno 2] No such file or directory only when I run the script via ssh. For example, if I run the script manually on the machine, there are no errors, but if I do ssh hostname --host hostname it generates...

Capistrano and Corkscrew PATH error

I'm trying to deploy my Rails application with Capistrano but when it comes to "git ls-remote" i get the following error: $ /usr/bin/env git ls-remote --heads [email protected]<server>:<project>.git /bin/bash: line 0: exec: corkscrew: not found DEBUG [a5205e2a] ssh_exchange_identification: Connection closed by remote host DEBUG [a5205e2a] fatal: The remote end hung up...