SSH remote command - ssh

I have a strange SSH problem.
If I run this
ssh user#remote 'md5sum file.txt'
I get back the result as expected, but if I run this
ssh user#remote 'cat file.txt'
then it just sits there.

I'll attribute this problems to bad network connection. I've started using Mosh and is works magnitudes better than ssh.

Related

Powershell SSH Tunnel closes unexpectedly

I have a powershell script that keeps closing ```ssh jumpbox_user#jumpbox_ip -p 22 -L port:server_address:port -i '~/.ssh/id_rsa' -N
The issue I have is that the tunnel will start but will then, randomly, it will close. I have this issue no matter how I start the SSH tunnel. I get the feeling that it has something to do, potentially, with my home internet? I don't seem to have this issue at work or at other locations. I've purchased a new router and a new modem to no effect, is there a way to check what is going wrong???

SSH connection to jupyter notebook opens but browser unable to connect

I have a bizarre problem with my SSH connection. I am trying to connect to Ubuntu server from Windows client (local network, Bitvise SSH client).
jupyter notebook --no-browser --port=8885
Everything launches as normal. I then go to my client
ssh -p 2222 -N -f -L 8800:localhost:8885 user#server
Everything seems normal and I get in. I then go my browser and try localhost:8800 and localhost:8885. Neither responds. Any tips would be appreciated. Many thanks.

Use "watch" over ssh

I want to write a script that connects via ssh (ssh user#host) and runs watch who there.
Normally I would just do
ssh user#host
# I am now on the other machine
watch who
But a spript would wait until the first command is done and would start the second one. So my next try is
ssh user#host watch who
but I get an error ($? is 1) and a message:
"Error opening terminal: unknown"
ssh user#host who works just fine though. So how could I approach this?
(My real application is not to watching the users but watching the print queue, but the problem seems to be the same and I guessed that more people are familiear with who then with lpstat)
The watch needs a PTY, which is not allocated when you add a command to ssh. Use
ssh -t user#host "watch who"

Docker: SSH freezes on login

I can succefully login to server using ssh 111.111.111.111 without password. But after multiple ssh login, I can't access server for some while(it freezes when I try to login).
To tell the whole story I'm trying to create generic docker machine using following lines.
docker-machine create\
--driver generic\
--generic-ip-address=111.111.111.111\
srv
All of the errors are ssh related, and they are quite randomly at different stages:
Error getting SSH command: Something went wrong running an SSH command!
command : cat /etc/os-release
err : exit status 255
output :
or:
if ! type docker; then curl -sSL https://get.docker.com | sh -; fi
SSH cmd err, output: exit status 255:
error installing docker:
After any of these error I can't login for somewhile. Please let me know if any log or confs is needed.
Since docker executes procedures via separate ssh command, somehow my provider detected me as an intruder for brute force attacks, changing the ssh port on remote server solved the problem.
Please view another question that I asked at
SSH parallel command execution freeze for this matter.

"Connection to localhost closed by remote host." when rsyncing over ssh

I'm trying to set up an automatic rsync backup (using cron) over an ssh tunnel but am getting an error "Connection to localhost closed by remote host.". I'm running Ubuntu 12.04. I've searched for help and tried many solutions such as adding ALL:ALL to /etc/hosts.allow, check for #MaxStartups 10:30:60 in sshd_config, setting UsePrivilegeSeparation no in sshd_config, creating /var/empty/sshd but none have fixed the problem.
I have autossh running to make sure the tunnel is always there:
autossh -M 25 -t -L 2222:destination.address.edu:22 pbeyersdorf#intermediate.address.edu -N -f
This seems to be running fine, and I've been able to use the tunnel for various rsync tasks, and in fact the first time I ran the following rsync task via cron it succeeded:
rsync -av --delete-after /tank/Documents/ peteman#10.0.1.5://Volumes/TowerBackup/tank/Documents/
with the status of each file and the output
sent 7331634 bytes received 88210 bytes 40215.96 bytes/sec
total size is 131944157313 speedup is 17782.61
Ever since that first success, every attempt gives me the following output
building file list ... Connection to localhost closed by remote host.
rsync: connection unexpectedly closed (8 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(605) [sender=3.0.9]
An rsync operation of a smaller subdirectory works as expected. I'd appreciate any ideas on what could be the problem.
It seems the issues is related to autossh. If I create my tunnel via ssh instead of autossh it works fine. I suspect I could tweak the environment variables that affect the autossh configuration, but for my purposes I've solved the problem by wrapping the rsycn command in a script that first opens a tunnel via ssh, executes the backup then kills the ssh tunnel, thereby eliminating the need for the always open tunnel created by autossh:
#!/bin/sh
#Start SSH tunnel
ssh -t -L 2222:destination.address.edu:22 pbeyersdorf#intermediate.address.edu -N -f
#execute backup commands
rsync -a /tank/Documents/ peteman#localhost://Volumes/TowerBackup/tank/Documents/ -e "ssh -p 2222"
#Kill SSH tunnel
pkill -f "ssh.*destination.address"