RoPod/Tutorials/ConnectingToRobot: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
(Created page with 'Go to you bashrc (cd to ~) and add the following lines at the bottom: <pre> alias sshpico="ssh ropod@192.168.44.81" alias pico-core='export ROS_MASTER_URI=http://192.168.44.81:1…')
 
No edit summary
Line 1: Line 1:
Go to you bashrc (cd to ~) and add the following lines at the bottom:
= Entering Pico from terminal via the network =
Go to your .bashrc-file (cd to ~) and add the following lines at the bottom:


<pre>
<pre>
Line 6: Line 7:
</pre>
</pre>


close the terminal and open a new one (such that the commands you just added when a new terminal is opened)
Here, some user-defined commands are given which actually execute some more complex ones. As the .bashrc is run each time you open a new terminal, you need to open a new terminal if you added these lines from your terminal.
 
If you want to
 
Now, connect to the AtHome-network (ask for the password). Running sshpico gives you access to pico in the ropod-user (again, ask for the password).
 
Once you are running some packages on the robot and you want to use the information published and topics (for example for visualization using rviz for example), then open a terminal and run pico-core. Now, from this terminal you can use these data on your own pc.
 
= Automatic key generation =
If you want to prevent using a password each time you want to log in to Pico, you need to generate a key. Therefore, you can use an automatic key generator, for example using the method copied from [https://superuser.com/questions/8077/how-do-i-set-up-ssh-so-i-dont-have-to-type-my-password | this] site running the next set of command from your local desktop system:
 
<pre>
ssh-keygen
</pre>
 
Make sure to use the default for the keyname. We suggest that you do set a passphrase on that key, otherwise it's a security problem. "-t rsa" wouldn't be a bad idea, but probably isn't needed.
 
ssh-copy-id ropod@192.168.44.81
 
That will ask you for the password you'd use to log in, and sets up the authorized_keys stuff for you. (no need to do it by hand)
Then, this:
 
<pre>
ssh-agent
</pre>
 
or maybe this:
 
<pre>
exec ssh-agent sh
</pre>
 
or:
<pre>
exec ssh-agent bash
</pre>
 
That will start up an SSH agent that can hold your key. On many modern Unix variants, if you're logged in graphically, this will already have taken place. The first variant (with the backticks) puts an ssh-agent into the background and sets up the environment variables to talk to it. The second two have the agent run a shell for you, so that when you exit the shell, the agent exits.
Many modern Unix variants will already have an agent running for you, especially if you logged in graphically. You might try "ps aux | grep ssh-agent" or "ps -ef | grep ssh-agent"; if something is already running, use that.
Then, finally:
 
<pre>
ssh-add
</pre>
 
It will ask for a passphrase; give it the one you gave ssh-keygen. There's also ways to make it ask graphically. And you can put the ssh-agent and ssh-add stuff into your login scripts (setup is different depending on shell you use) to automate this, but some Unix variants (current Ubuntu Linux, for instance) do most of that automatically, so that all you really need to do is create a key and use ssh-copy-id to set it up on the remote host.
Now, "ssh ropod@192.168.44.81" (or sshpico in our case!) should work without asking for any authentication. Behind the scenes, it's using a key that the ssh-agent is holding, and asking the agent to do the magic signing tricks for it.

Revision as of 15:00, 17 July 2017

Entering Pico from terminal via the network

Go to your .bashrc-file (cd to ~) and add the following lines at the bottom:

alias sshpico="ssh ropod@192.168.44.81"
alias pico-core='export ROS_MASTER_URI=http://192.168.44.81:11311'

Here, some user-defined commands are given which actually execute some more complex ones. As the .bashrc is run each time you open a new terminal, you need to open a new terminal if you added these lines from your terminal.

If you want to

Now, connect to the AtHome-network (ask for the password). Running sshpico gives you access to pico in the ropod-user (again, ask for the password).

Once you are running some packages on the robot and you want to use the information published and topics (for example for visualization using rviz for example), then open a terminal and run pico-core. Now, from this terminal you can use these data on your own pc.

Automatic key generation

If you want to prevent using a password each time you want to log in to Pico, you need to generate a key. Therefore, you can use an automatic key generator, for example using the method copied from | this site running the next set of command from your local desktop system:

ssh-keygen

Make sure to use the default for the keyname. We suggest that you do set a passphrase on that key, otherwise it's a security problem. "-t rsa" wouldn't be a bad idea, but probably isn't needed.

ssh-copy-id ropod@192.168.44.81

That will ask you for the password you'd use to log in, and sets up the authorized_keys stuff for you. (no need to do it by hand) Then, this:

ssh-agent

or maybe this:

exec ssh-agent sh

or:

exec ssh-agent bash

That will start up an SSH agent that can hold your key. On many modern Unix variants, if you're logged in graphically, this will already have taken place. The first variant (with the backticks) puts an ssh-agent into the background and sets up the environment variables to talk to it. The second two have the agent run a shell for you, so that when you exit the shell, the agent exits. Many modern Unix variants will already have an agent running for you, especially if you logged in graphically. You might try "ps aux | grep ssh-agent" or "ps -ef | grep ssh-agent"; if something is already running, use that. Then, finally:

ssh-add

It will ask for a passphrase; give it the one you gave ssh-keygen. There's also ways to make it ask graphically. And you can put the ssh-agent and ssh-add stuff into your login scripts (setup is different depending on shell you use) to automate this, but some Unix variants (current Ubuntu Linux, for instance) do most of that automatically, so that all you really need to do is create a key and use ssh-copy-id to set it up on the remote host. Now, "ssh ropod@192.168.44.81" (or sshpico in our case!) should work without asking for any authentication. Behind the scenes, it's using a key that the ssh-agent is holding, and asking the agent to do the magic signing tricks for it.