autossh -ND at Ubuntu boot

Faisal

I have setup key-less login at a remote server. I use the remote server for tunneling my data. I want my local system to ssh into the remote server at boot time automatically.

I tried the solutions suggested in the following links but none of them worked for me:

  1. How to launch a SSH tunnel with upstart
  2. How do I make a script run upon startup of the Ubuntu machine?
  3. Autossh with Ubuntu Upstart

I did what was mentioned in those posts. The autossh command should open a port (9090 in my case) so that I can tunnel my traffic. After applying each of those methods, I restarted the PC and upon reboot I ran nmap to see if the particular port was listening or not. Sadly, in each case the port was still closed so I have to manually enter the command at terminal every time I reboot my PC.

Can some one help me? Do note that the remote server and my local system are both running Ubuntu 14.04, and the local system has no GUI installed.

Rmano

I have this little script kept in ~/bin/infinite_ssh(1):

#! /bin/bash -x
#
while :; do 
         ssh -R 2222:localhost:22 remoteserver sleep 86400
         sleep 10
done

this is connecting to the remoteserver and creates a backward tunnel so that in the remote server I can ssh my desktop by using ssh -p 2222 localhost. Your application may, obviously, vary. The remoteserver is defined in ~/ssh/config so that you can login without a password, and has KeepAlive on option.

Then you can call it from /etc/rc.local with

su -l youruser -c /home/youruser/bin/infinite_ssh &

so that it starts as your user at boot time, in background.


Footnotes:

(1) obviously, you need to give the script execution permission... chmod a+x ~/bin/infinite_ssh.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Ubuntu 부팅시 autossh -ND

분류에서Dev

Ubuntu 부팅시 autossh -ND

분류에서Dev

Ubuntu에서 부팅시 autossh로 역 터널 시작

분류에서Dev

Ubuntu doesn't boot!

분류에서Dev

Boot to Btrfs snapshot in Ubuntu

분류에서Dev

Unable to boot Ubuntu

분류에서Dev

Inability to Boot to Ubuntu

분류에서Dev

Ubuntu 14.04: Boot Repair is not working (No Boot Menu)

분류에서Dev

Can Not Boot to Ubuntu - Windows 8/Ubuntu 13.04 Dual Boot

분류에서Dev

How to get the boot time of Ubuntu?

분류에서Dev

Ubuntu takes 7 minutes to boot

분류에서Dev

Ubuntu 12.04 USB Boot Stuck

분류에서Dev

BOOT Ubuntu 12.04.3 in UEFI mode

분류에서Dev

Ubuntu Dual boot 제거

분류에서Dev

Dual Boot Windows 10 with Ubuntu

분류에서Dev

Can not boot to Ubuntu after installing it

분류에서Dev

Can not boot ubuntu and other linuxes

분류에서Dev

Ubuntu splash screen not showing at boot

분류에서Dev

Unable to boot to Ubuntu after a restart

분류에서Dev

systemd로 부팅시 Autossh

분류에서Dev

Cannot boot to Windows after installing Ubuntu and running boot-repair

분류에서Dev

No boot menu for Ubuntu 14.04 after dual boot installation

분류에서Dev

Cannot boot Windows from USB, but can boot Ubuntu

분류에서Dev

Unable to boot Windows 10 after installing Ubuntu. Legacy boot

분류에서Dev

Cant boot Ubuntu 14.04 after dual boot with fedora 23

분류에서Dev

Unable to boot ubuntu 13.04 alongside windows 8

분류에서Dev

Ubuntu Won't boot after Bootcamp Expansion

분류에서Dev

Dual boot Ubuntu 12.04 and Windows 7 PROBLEM

분류에서Dev

Ubuntu iso boot load stuck in Virtual Box