Start a ssh login shell using existing connection - c

My application has an existing ssh connection to a remote server. This application has an socket on the localhost. How can I start a login shell using this existing connection, simular to
ssh user#host
does.
Of course my application has to use some api when a program connects to the socket and wants to start a remote shell. (I can use The Secure Shell (SSH) Transport Layer Protocol https://www.rfc-editor.org/rfc/rfc4253 for that), thats not the problem. My problem is how to redirect stdin and stdout and stderr from the terminal/konsole to the socket.
Can someone give a hint about that? Thanks in advance.
(I have an fuse fs which provides sftp access to different folders on the server, it would be awesome when it can also offer terminal access to the server and possibly a chat session using ssh-chat... user has toc click on a desktop file my fuse fs provides, and the right program is started to make the connection to socket and start the terminal. This of course only works in a graphical environment)

Related

Telnet/ssh server that runs a nodejs script in interactive mode

I've been using Ink (https://github.com/vadimdemedes/ink) to create a simple nodejs cli tool using React. Currently all it does is ask some questions and then displays a response. I'd like to create a daemon/server that will listen for incoming connections, and then run that nodejs script in interactive mode so the connected user will see be able to see the scripts output and be able to interact with it and see the response.
I know I can probably mod Ink to do this and act as a server, but I was wondering if and how this might be possible with something like tcpserver, xinetd, socat or similar.

is it possible to use SSL_connect for http?

Is it possible to use SSL_connect() and related API of OpenSSL, for "http" connections ALSO? My program reads the hostname from the command prompt in linux terminal as argument to command, and I don't want to write two different codes switching between "http" and "https" for fetching web-pages..... So just using SSL connection API functions, is there a way to connect to a web server on port 80 without encryption? For the sake of reusing same code simply.

dbus c api example doesn't work

I work on UBuntu 12.04 LTS. I'm trying to use sendsignal and receive functions from this site but they don't work correctly. In my program I first call sendsignal("mySignal) then receive(). I get following info:
Sending signal with value mySignal
Name Error(Connection ":1.95" is not allowed to own the service "test.signal.source" due to security policies in the configuration file)
Because of that I replaced conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); with conn = dbus_bus_get(DBUS_BUS_SESSION, &err); in both functions. Now a signal is sent but receive function doesn't see that signal, i.e. NULL == msg that's true. I also commented out dbus_connection_close(conn); because of the following error:
process 12612: Applications must not close shared connections - see dbus_connection_close() docs. This is a bug in the application.
How to make it working ?
Maybe try:
Run dbus-launch in a terminal. Copy and paste the terminal output to a file, and edit it to export the content as environment variables. By doing this, you launch a new dbus daemon and exposes it to the subsequent application.
Source the environment setting file in your terminal before running both the signal sending and receiving examples. This makes the app connects to the new session bus.
I'm guessing your sending example is launching its own dbus daemon, but the other app does not have a clue what the daemon is, thus you need to expose the daemon through an env variable. Another possible cause is your sending and receiving application are using the defaule login session bus but the policy does not allow them to use.
Let us know if this works or not.

Remotely start session on display :0

I am working remotely and had to restart. I can start a vnc session and log into that. But for some reason the program I'm trying to use gives a GLX error when I try to start it. (I'm using xfce4).
I've circumvented this problem in the past by using an x11vnc session into my display :0. To do this, I open a regular vnc session, and type in a terminal
x11vnc --display :0 --forever
Then I close the vnc session, and log into the x11vnc session.
But this isn't working now because, since I had to restart, I think I don't really have a display :0 running because I have not logged into a desktop session on site.
The question is: is there any way I effectively log into a desktop session remotely, so it would be as if I had logged into my computer on site, and can then use x11vnc as I described above.
(Caveat: I'm not an expert in all these things, so I may have used some incorrect terminology. But I think the question is clear).
Thanks!
============== added ================
Maybe a clarification would be the following. Can I trick the computer into thinking that I am sitting right in front of it? Can I start a session remotely such that when I next sit down in front of the computer it will appear that I have already logged in? I'm certain this would solve my problem. No other combination of VNCing seems to work.
============== More ======================
I just restarted (remotely), ssh'd in, and typed
x11vnc --display :0
This is what I got
** If NO ONE is logged into an X session yet, but there is a greeter login
program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
to find and use the raw display manager MIT-MAGIC-COOKIE file.
Some examples for various display managers:
gdm: -auth /var/gdm/:0.Xauth
-auth /var/lib/gdm/:0.Xauth
kdm: -auth /var/lib/kdm/A:0-crWk72
-auth /var/run/xauth/A:0-crWk72
xdm: -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
dtlogin: -auth /var/dt/A:0-UgaaXa
but none of those options worked. I also tried the other suggestions, such as using -auth guess.
Display :0 is always running, assuming you have an X session running and your computer has booted up. The command x11vnc --display :0 --forever opens a VNC listening port on your machine that you can connect to with a VNC client.
Your initial vnc connection where you run the x11vnc command is not really necessary if you use SSH (a remote shell). If you install SSHD, and connect via ssh username#hostname you can run the command x11vnc --display :0 --forever from there, eliminating the need for the initial VNC connection.
If you don't have sshd running, you may be out of luck unless some sort of screen sharing is running. To see if there's any way to remote into your computer, run a port scan with NMAP.
Use tightvncserver. If you have apt, you can run sudo apt-get install tightvncserver to get it.
To Run the Server: tightvncserver, it will prompt for a password to use to authenticate VNC connections.
You should see a message New 'X' desktop is HOSTNAME:1. You now you have two X displays running. You can connect to the VNC Server on port 5901, since tightvncserver defaults to incrementing from port 5900.
This second X display (:1) is separate from display :0, so to someone standing at your remote computer, they will just see the login screen. This will last until the next reboot, though there are ways to have this command execute on startup.
Keep in mind, although tightvncserver will prompt for a password, and will use that password for authentication, VNC has been known to have vulnerabilities. So, if security of your computer is an issue, it's safer to tunnel the connection via ssh and firewall port 5901 from any connections except localhost.

EndpointNotFoundException on client machine

My WCF Service is hosted under net.tcpbinding and in case it is not running when client makes a call to its methods but let me tell you our some of clients get access and some of not. i even check antivirus setting and firewall setting for each client but haven't came up with right answer , client gets the EndpointNotFoundException with this message:
There was no endpoint listening...
i have check the path of service there is no mistake in path. and in my nettcp service based on window credential type and enabletcpportsharing is also on.
Still searching for right solution.
Thank you!
After trying telnet (IP Address of app server) Port. so i can understand it's blocking by window firewall or router firewall. if telnet open window from client machine that's mean its working and if not opening in window then call Network administrator to open that port
Eg. telnet xxx.xx.xx.xx 80 in command prompt

Resources