Auto SSH

  • Hey, Sorry if this is the wrong place to ask.


    I have Debian 11 installed on a VM in OMV. I was wondering is there a script or something that I can set up where when I log in a terminal window will opens and auto ssh?

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

  • Not sure I understand your question correctly, but you could add a line ssh STUKguy@ip.of.your.OMV to ~/.bahrc


    Read about .bashrc in linux

    Hey,


    So basically when i log in i want a terminal window to open on screen and for it to SSH automatically into the address

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

  • I am using GNOME, but from the link when i type in

    Code
    gnome-session-properties

    i get

    Code
    root@VMMine:/home/liton# gnome-session-properties
    bash: gnome-session-properties: command not found

    i thought it was not installed so i looked up the command to install and got this

    Code
    root@VMMine:/home/liton# apt-get install gnome-session-bin
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    gnome-session-bin is already the newest version (3.38.0-4).
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
    root@VMMine:/home/liton#

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

  • I thought would approach this step by step so i found this post from 2017 https://unix.stackexchange.com…-terminal-on-debian-login which seems to have worked, i restarted the machine a couple times and a terminal window opens now, What would be the next steps in to auto ssh'ing once the terminal window is open?

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

    • Offizieller Beitrag

    I thought would approach this step by step so i found this post from 2017 https://unix.stackexchange.com…-terminal-on-debian-login which seems to have worked, i restarted the machine a couple times and a terminal window opens now, What would be the next steps in to auto ssh'ing once the terminal window is open?

    I've read this 3 times and I can't tell if you're using a Linux client or a Windows client... so I'll just tell you how I do it with a Linux client. While I don't know what you've done thus far... This is how I've always set up automatic SSH on my Linux clients. It might seem a little long, but rest assured I'm just being long winded to try and be clear. It's really quite easy.


    All commands done on client


    1. ssh-keygen

    2. take defaults (no passwords, locations, etc.)

    2. ssh-copy-id server_user@server_ip

    3. accept fingerprint and enter server_user password

    4. When complete it you should get that a message a key was added.

    5. ssh server to test, and no password should be required.


    Now to set up a "one click SSH".... On a Linux client (I have no idea how to do this from Windows)...


    I install an alternative terminal program. ie... If I'm using XFCE desktop, I'll install the gnome-terminal app since there are few dependency issues between the two. This will essentially give me two terminal programs on my client.


    I open gnome-terminal (which is the app I'll use to auto SSH).. and usually I set the color palette to be different from my desktop terminal. So, for instance, my desktop terminal (xfce-terminal) is White on Black, while my gnome-terminal, which is to SSH OMV, is set to be Black on White, so it makes it easy to immediately distinguish which machine I'm running the commands on. This way I never accidentally confuse the two (ask me why I decided to do this..lol)


    After I set the color palette, I click Edit/Preferences/Command Tab and then enter a command to run when the app is opened. Obviously the command I want to run, is ssh server_username@server.ip


    Save and close. Now if I open up gnome-terminal, it should open up and automatically SSH my server, and since I'm using passwordless.. I'll basically be sitting at my OMV user prompt.


    Finally, I usually just create a shortcut on my panel, desktop, wherever I want it, and give it a distinct name (NAS terminal, Server terminal, etc.) so there's no question what it's doing. Then from then on if I want to SSH my server, I click that icon and I'm logged in.

    • Offizieller Beitrag

    i restarted the machine a couple times and a terminal window opens now, What would be the next steps in to auto ssh'ing once the terminal window is open?

    In that terminal proceed like described in post #2

  • It is a Linux client. I am using a VM of Debian 11 to ssh into other Debian machines. I will try how you suggested. Currently I'm having some problems with my set up but once that's fixed I will try what you said.


    Thank you though

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

  • I open gnome-terminal (which is the app I'll use to auto SSH).. and usually I set the color palette to be different from my desktop terminal. So, for instance, my desktop terminal (xfce-terminal) is White on Black, while my gnome-terminal, which is to SSH OMV, is set to be Black on White, so it makes it easy to immediately distinguish which machine I'm running the commands on. This way I never accidentally confuse the two (ask me why I decided to do this..lol)

    KM0201 sorry going through old post trying to finish what is started, i'm intrigued why did you do that?


    I followed what you said but i think i might still be doing it wrong, and reading through my post i think i may have confused everything even more so lets say i have figured out how to automatically open 3 terminal windows upon log in


    terminal 1

    i want to run "watch sensors"


    terminal 2

    i want it to ssh into 123.123.12.1 (i have set up ssh keyless entry)

    and then run "watch sensors"


    terminal3

    same as terminal 3 only different IP


    i did what you suggested about edit/preferences and then run command, but that appeared to copy the command into all terminal windows.

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

    • Offizieller Beitrag

    Yeah, it would.


    I'm not sure how you could make it run a command after SSH'ing in to the server.

  • Yeah, it would.


    I'm not sure how you could make it run a command after SSH'ing in to the server.

    Ah ok, guess just manually do it unless i want to learn about scripts

    Normally if its in red it's bad!!!


    Machine 1 - Dell OptiPlex 790 - Core i5-2400 3.10GHz - 16GB RAM - OMV5

    Machine 2 - Raspberry PI4 - ARMv7 - 2GB - OMV5

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!