Open leoheck opened 3 years ago
@leoheck thanks for contacting us. Take a look at https://docs.shellhub.io/user-manual/devices/connecting/
Thanks, I don't need to use shellhub. These browser only applications slow down the whole process. I don't need it at all. But these guys from my team is using it. So, then I was thinking that it would be perfect if you guys coud have a command line tool that connects to the shellhub and allows easy access to the machines there. This would be a real improvement for shelhub.
As mentioned, it is possible to connect from command line as explained on the link I pointed above.
Maybe I am failing to explain this. I know how use the ssh. I know how to use the shellhub to connect into a device. Now, what I am saying is to have a tool (command line tool), lets call it shellhub
then we cloud do like this
connect to the platform with my credentials $ shellhub leandro password: ****
This is going to ask my password and will give me a terminal with some commands like
list_devices connect_device DEVICE_NAME
Then a advanced user could use this form the command line, and also from a computer that does not provide any gui.
A command-line UI is indeed a very good idea. We need people to help to do it thought. Are you willing to help here?
Yeah, definitely. Do you have any info to share to get access so I can try something? I was trying briefly to get access to the website from the command line with curl yesterday but the very quick test I made I was seeing a response saying I needed javascript support.
-- Leandro Heck
On Mon, Oct 4, 2021 at 11:07 PM Otavio Salvador @.***> wrote:
A command-line UI is indeed a very good idea. We need people to help to do it thought. Are you willing to help here?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shellhub-io/shellhub/issues/1324#issuecomment-933998601, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJX7YAZTD7ETMFKMNYKISTUFJMVHANCNFSM5FKIM7QA .
We're publishing the OpenAPI docs in next release. Those are a good reference.
Beautiful, thanks.
@gustavosbarreto do you have any example of how I can get a list of my devices with curl?
more precisely, a list of the ssid fields
Alright, this is working fine for me.
# Get the Bearer token using cURL and jq
TOKEN=$(curl -s -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' --data "${login_data}" "${URL}/api/login" | jq -r '.token')
Now, how do I get the devices list? I am not getting the devices with this command https://docs.shellhub.io/api/#tag/device/paths/~1api~1devices/get
It looks like it is getting a single computer.
Ah, it has query parameters. It would be good to have some examples of the payload in the right panel, maybe.
Even after using this, I am just getting the first one.
This is what I am trying right now.
ah, it looks like what I want to access is this. https://docs.shellhub.io/api/#tag/session/paths/~1api~1sessions/get
Or maybe not. There is something weird going on.
How do I show all my devices? I can just list one. I have at least 20. Do you have any idea?
Alright, it looks that I am just seeing one of the namespaces. How do I change the namespace?
This is getting namespaces
Devices count is 17 while devices is 0, this is strange. Sessions is 0 too. Are you sure these numbers are right? I meant, are they returning the right info?
This is getting namespaces
Devices count is 17 while devices is 0, this is strange. Sessions is 0 too. Are you sure these numbers are right? I meant, are they returning the right info?
@henrybarreto can you please take a look into this?
This is getting namespaces Devices count is 17 while devices is 0, this is strange. Sessions is 0 too. Are you sure these numbers are right? I meant, are they returning the right info?
@henrybarreto can you please take a look into this?
Yes, I can.
I'll check what is happening.
How do I show all my devices? I can just list one. I have at least 20. Do you have any idea?
Even after using this, I am just getting the first one.
This is what I am trying right now.
How do I show all my devices? I can just list one. I have at least 20. Do you have any idea?
Hi, Leo.
If I'm not misleading, --data
in cURL is to send a data inside the request's body, but to list devices, you need to send it as query parameters, so your request will become this:
curl -s -X GET -H 'Authorization: Bearer token' -H 'Accept: application/json' 'localhost/api/devices?per_page=20&page=1'
Hi. The -d or --data (to send a json) are the same as you are showing. I got more data with the session list instead of the devices list
My current issue is how do I change the namespace. Those commands access my development namespace and couldn't find any way to change the namespace yet.
On Wed, Dec 1, 2021, 23:17 Henry Barreto @.***> wrote:
How do I show all my devices? I can just list one. I have at least 20. Do you have any idea?
Even after using this, I am just getting the first one. [image: image] https://user-images.githubusercontent.com/1277920/144286672-dfd73c77-2ac5-464b-afc6-3609b500b674.png
This is what I am trying right now. [image: image] https://user-images.githubusercontent.com/1277920/144286748-0f39ca0f-821f-4df3-8c27-5c1414dedd6c.png
How do I show all my devices? I can just list one. I have at least 20. Do you have any idea?
Hi, Leo.
If I'm not misleading, --data in cURL is to send a data inside the request's body, but to list devices, you need to send it as query parameters, so your request will become this:
curl -s -X GET -H 'Authorization: Bearer token' -H 'Accept: application/json' 'localhost/api/devices?per_page=20&page=1'
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shellhub-io/shellhub/issues/1324#issuecomment-984230068, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJX7YCNWI42BVTEJNUITEDUO3JKFANCNFSM5FKIM7QA .
Sorry, so. :D
To "change" namespace, you need to do a GET request to http://localhost/api/auth/token/<namespace's tenant>
. It will return to you a new token that "points" to this new namespace.
This was my last try some minutes ago. Let me check... AH, it looks like the /auth/
path was missing...
Please, check your API docs, it looks like it misses this info t/api/auth/token/<namespace's tenant>
I tried to locate it now quickly and I was not able to.
This is what I was trying. Note the different (wrong) URL I was using.
perfect, got the token. now, how do I use it? it is just a matter of replacing the normal token I was using?
This was my last try some minutes ago. Let me check... AH, it looks like the
/auth/
path was missing...Please, check your API docs, it looks like it misses this info
t/api/auth/token/<namespace's tenant>
I tried to locate it now quickly and I was not able to.
Okay. It is true; I've forgotten this route.
As soon as possible, I'll add this.
Thank you :D
perfect, got the token. now, how do I use it? it is just a matter of replacing the normal token I was using?
Exactly.
Any suggestion on how do I use the token? Just replacing the token I as using did not work.
See line 104. this is not working.
ah it worked. it happens that it has just 1 device and no active sessions.
ah it worked. it happens that it has just 1 device and no active sessions.
:D
So... Everything is okay?
Nice, now it is working! Thank you guys
Yeah. I was able to get all devices, on all my namespaces.
Your docs could have curl commands as an example of each command because they are easy to test. Some APIs have this kind of thing. I will share my simple script tomorrow, you could use something to help you improve the docs, if needed.
Your docs could have curl commands as an example of each command because they are easy to test. Some APIs have this kind of thing. I will share my simple script tomorrow, you could use something to help you improve the docs, if needed.
Yeah, you are right, and I'll do.
The API documentation have some points to be improved; examples is one of them.
It seems that your script will be helpful.
I put some commands I was using, on a gist here https://gist.github.com/leoheck/430698751f17d679d5e9b142280cb03c
I am also using jq
as JSON parser.
hello guys! all links missing, i want to connect to shellhub's devices via SSh, someone can help please?
Hello @diegofpk,
Please take a look at this link https://docs.shellhub.io/user-guides/devices/connecting#command-line-ssh-client to learn how to connect to a device using the SSH command line.
It's a helpful guide that will walk you through the steps you need to take to establish a secure connection.
Let me know if you have any questions or need further assistance!
Hello, how do I connect shellhub form ssh? Do you have any tutorial?