On manjaro ssh-add only works in the window i execute it in - manjaro

I'm pretty new to stack overflow, so I don't know how to refer to previous question. I understand that
eval ssh-agent -c
starts my ssh-agent in my instance, and that I can then execute ssh-add. How do I get ssh-agent to come up at start-up, and how do I get the passphrase to be global? I'm running Rocky on another machine and ssh-agent seems to already be working whenever I fire up a new window. I'm using the newest version of Manjaro-kde
In Manjaro-kde, running tcsh in a new window, I issued
eval ssh-agent -c
which started ssh-agent. I then used ssh-add with the appropriate passphrase, and, in that window, I can use a dsa or rsa public key without reissuing the passphrase. However, when I bring up another window, ssh-agent is not running, so I have to go through exactly the same process. This gets really old.
On my Rocky machine, I never have to start ssh-agent, and I only have to issue ssh-add in one window for the passphrase to be known in all windows.
I want the Rocky behavior on Manjaro.

Related

Using docker context to a mac

I had been trying to create a context to deploy a few containers from my main Mac to another another but I have been getting a weird error.
So, I have two Macs, one iMac (Late 2013) (here will be called Enterprise) and one Macbook Pro (Mid 2015) (here will be called Defiant). Defiant is my main computer and I want to deploy my container to Enterprise in order to not overload Defiant memory. I have been working with docker context to achieve that. Currently, I have Enterprise running Docker v20.10.16 and Defiant running v20.10.16.
I have created the context on Defiant and after I run the docker context use enterprise and when I run docker container ls I get the following error:
error during connect: Get "http://docker.example.com/v1.24/containers/json": command [ssh -l rafaelguerra -- Enterprise.local docker system dial-stdio] has exited with exit status 127, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=zsh:1: command not found: docker
Does anyone know how to make it work?
Thanks
UPDATE:
Weird thing I just found out, when logged into Enterprise and run echo $PATH returns /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin however when I run ssh rafaelguerra#enterprise.local 'echo $PATH' I got the following /usr/bin:/bin:/usr/sbin:/sbin
I don't have a clue for a reason for this.
I found the reason for the problem, all commands docker run are run within ssh not with a permanent ssh session. So, zsh does not load the correct PATH when the command is run within the ssh. Therefore, the only thing I need to do was setting the correct PATH inside of the ~/.zshenv file and everything is working now.

Using SSH in a Docker container (Windows)

Starting from the microsoft/aspnetcore docker image, I was able to install chocolatey and then use chocolatey to install some other software:
open-ssh
git
Now I want to clone a repo from our Bitbucket server:
I added the Bitbucket server to the known_hosts file (and even ssh'd into the server from the container to double-check)
I added my Bitbucket ssh key, which I've been using successfully on my machine and used successfully from an Ubuntu container
I added a config file in my user's .ssh directory to tell git to use my ssh key
I expect to be able to use git clone ssh://git#<host>/<path to repo>, but this command always fails with the following error:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
I got this to work in an Ubuntu container with the following command:
ssh-agent sh -c 'ssh-add /home/bamboo/.ssh/id_rsa; git clone ssh://git#<host>/<path to repo>', but this command seemingly does nothing on the Windows container. I never get any feedback from ssh-agent so I am unsure if Open-SSH is even working or if there are known issues of Open-SSH in Windows containers? I do get feedback from ssh-add saying that my key was successfully added, but still I am unable to clone my git repo.
Has anybody been able to successfully do this in Windows containers? It works on my Windows machine but I'm not using Open-SSH, I'm using the Git Bash tools, which don't work in the Windows container. This is all very confusing because all the information on this topic pertains to Ubuntu containers and the resolutions all involve Unix commands that I don't have available in the Windows container.
Another strange thing I notice is that cloning using HTTP doesn't work either, instead I get the following error:
error: failed to execute prompt script (exit code 66) fatal: could not
read Password for 'http://(user)#(host)': No error
I got a little help from the Git for Windows people who suggested I use the verbose flag with the ssh command, i.e. ssh -vvvvv <host>. This showed that the config file I had in my user's .ssh directory had some extra permissions, indicated by an error message:
debug3: Bad permissions. Try removing permissions for user: S-1-5-11 on file C:\Users\ContainerAdministrator/.ssh/config
Using the icacls utility I was able to remove those permissions, which allowed the config file to be used.

How do I write a shell file to type in a password under macOS?

I'm working on a simple app that would automatically ssh into my iPhone and run some commands. The thing is that the ssh command asks fro password and I'm not exactly sure how do I write a shell file so it would automatically input that password. My code for now looks like this:
ssh root#192.168.1.19
<here should be a code to type in the root password>
nimbus help
<some other commands>
Nimbus is an app I'm running through ssh to remotely control the phone.
The correct way would probably be to use key-based authentication and add the right SSH key to your ssh-agent.
If that's not possible or you absolutely want to use password-based authentication, you can use sshpass.
You'll have to install it either manually or, if you are using Homebrew, by adding the custom formula at http://git.io/sshpass.rb.
Homebrew won't officially package it:
We won't add sshpass because it makes it too easy for novice SSH users to
ruin SSH's security.
So be careful.

'nutc': unknown terminal type. docker

I have a windows 7 box. I am trying to run Docker quickstart. It keeps dying with the following error...
Starting "default"...
(default) Check network to re-create if needed...
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses. You may need to re-run the `docker-m
achine env` command.
Regenerate TLS machine certs? Warning: this is irreversible. (y/n): Regeneratin
g TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
'nutc': unknown terminal type.
Looks like something went wrong in step ´Finalize´... Press any key to continue.
On doing a search on the internet I can see that some people have suggested commenting out clear in start.sh which I have also tried but doesn't seem to fix the problem.
Has anyone got any ideas on how I might get past this?
thanks
Solution for Windows 7 Docker ToolBox:
cd to installed folder Ex: "C:\Program Files\Docker Toolbox"
then, type "bash" and enter
run "./start.sh"
hope it works.
It breaks on the "clear" command in the start.sh script (corresponding to the "Docker quickstart Terminal" icon)
If you comment the clear command just after STEP="Finalize"
adding a # like that
#clear
At least like taht the it will run.
Personnally my terminal has then problems with backspace key and arrows keys.

Console Utility that can remote connect to other systems and issue commands

Frequenlty my work involves to VNC to a remote system and work on it. SInce i run command line apps on this remote system most of the time, i was wondering if there's an alternative software to command prompt which i could install on my local machine. Using this i should be able to create a session with the remote system and from then on all commands issued in command prompt should run in remote system.
localHost>dir --> should list the directory contents in remotehost active directory
localhost>app.exe should run app.exe in remote host and display its contents in localhost command prompt
I browsed a little and read about cmdlets in powershell. But it looks like i need to write a cmdlet for each app in the path (dir, mkdir, app.exe in the path). Correct me if am wrong. Once session is established, i simply need the commands invoked in local host to be run in the remote host and return the console output to local host. Please let me know if powershell + cmdlets are the only way
THanks
Just use PowerShell Remoting if it can be set up (requires a little preparation).
I'm not quite sure why you think of writing own cmdlets for stuff that's already there. dir is an alias to Get-ChildItem which does return the items in the current path (and—depending on options—some other stuff as well). And since PowerShell is a shell it has no problems running external programs too.
SSH is what you're looking for. Cygwin has a SSH server and client.
Unix people do this all the time with SSH. You can install the sshd server on your remote machine through Cygwin, then use PuTTY to connect to it.
As a bonus, PuTTY does not use the clunky Windows cmd.exe program; it's got a much nicer terminal of its own.
You could maybe even run PowerShell on the remote end, so you don't have to learn bash.
Depending upon on how you actuall access the machines PSExec may be an alternative that wont require you to install anything on the remote system.

Resources